navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Using OnChange to post form back to itself

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Using OnChange to post form back to itself
Page: [1]
 
and13345

 

Posts: 99
Joined: 10/7/2003
Status: offline

 
Using OnChange to post form back to itself - 11/17/2005 21:43:29   
I have a form that i am using to populate a DB. I can easily create dynamic DD lists using ASP when the page loads. I have 3 dropdowns that are each dependant on each other. In other words the selection in dd1 needs to filter the options for dd2 and then for dd3. I can handle the filtering and generating the dropdowns using the OnChange and posting the form back to itself, but what I am stumped on is how can I use the OnChange to post back to itself and still have a submit button to submit that form to an insert.asp script that submits the data to a DB? This is going to be low usage and I am not concerned about posting that page back to itself. I think this is the simplest way for me, I just can't think of how I can post back to the same page 3 times and then have a submit button that submits all that data to an insert.asp script.

Any ideas?
rdouglass

 

Posts: 9227
From: Biddeford, ME USA
Status: offline

 
RE: Using OnChange to post form back to itself - 11/17/2005 23:17:32   
quote:

I just can't think of how I can post back to the same page 3 times and then have a submit button that submits


With three menus the 3rd submit would be the final one correct?

If that's the case, one way might be to put a querystring on the second dropdown URL that includes some kind of identifyer to allow the page to show the final submit button. Something like this in your second dropdown:

<a href="myPage.asp?myCategory=1&canSubmit=y">

and wrap the actual submit button inside an IF...THEN statement:

<%IF request.querystring("canSubmit") = "y" THEN%>
<input type="submit" value="Submit">
<%END IF%>

That might be one way anyways. Without knowing more specifics, I can only guess.

Hope it helps.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to and13345)
and13345

 

Posts: 99
Joined: 10/7/2003
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 0:02:09   
Maybe I should give more detail on what I am after. I have a form that has a lot of data on it. 3 of the pieces are OEM Name, OEM Division & OEM Contact. In my submission form, I am using a querry of the current DB records to generate these three drop downs. So if an OEM name has been listed before it appears in the list the next time I open the form. I don't have a separate DB with the records for these dropdown boxes. If I need to enter a new OEM, something I haven't used before I have a value called Enter New that unhides a text field that is used as the entry field for that dropdown. I have all that figured out, so what I want to do now is say I have OEM A, B & C in my first drop down. My second dropdown is Division. Based on the OEM I choose, I want the Division dropdown to only choose the Divisions for the OEM Name that I selected. Then the third is Oem Contact. So I know how I can filter the dropdowns when I post the page back to itself, but I am not sure how I can then at the end submit the entire form to an database insert script. Currently my form starts with this.

<form METHOD="POST" action="insert.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1" language="JavaScript">

and I have several fields including the 3 dropdowns. If I use "onchange=this.form.submit()" on the dropdowns, won't it try to submit to the insert.asp page and not back to this page (called new.asp)? What I need is for the dropdowns to submit back to new.asp and when I click on the final submit button it submits to insert.asp.

Does that make sense or am I confusing you more?

(in reply to rdouglass)
rdouglass

 

Posts: 9227
From: Biddeford, ME USA
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 9:08:41   
quote:

"onchange=this.form.submit()" on the dropdowns, won't it try to submit to the insert.asp page and not back to this page (called new.asp)?


I think my idea would still be valid.

Using the same scheme as before, you could do something like:

<%IF request.querystring("canSubmit") = "y" THEN%>
<form method="post" action="insert.asp">
<%ELSE%>
<form method="post" action="new.asp">
<%END IF%>

You can still use the JavaScript to submit but just change the form action depending on whether you're at the last step or not.

Did that make any sense at all?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to and13345)
and13345

 

Posts: 99
Joined: 10/7/2003
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 9:22:02   
Yes, that made sense, but I think I will put a bit of a twist on that. I have two more dropdowns on my form after these three and one of them (oem_build_shipped) is required. I think what I will do is have that one other field post back to the form on change and do a check on that field and if it contains a value then enable the submit button to post to the insert.asp. Something like this.

<%IF request.form("oem_build_shipped") = "Yes" OR request.form("oem_build_shipped") = "No" THEN%>
<form method="post" action="insert.asp">
<%ELSE%>
<form method="post" action="new.asp">
<%END IF%>


The reason is because if I make a mistake in setting the three dropdowns, I can still modify them before submitting to insert.asp.

I will give this a try and see how it works.

Thanks for the feedback!!

(in reply to rdouglass)
and13345

 

Posts: 99
Joined: 10/7/2003
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 10:30:53   
I am running to a bit of a problem when I use an IF to determine what the FORM header should have. Below is the code I am using and at the bottom is a copy and paste of what the page is generating. The problem is that I have some onchange javascript that runs when a couple of other fields are changed and it is breaking that because the form name is not what it should be. See the name is FrontPage_Form1 and in one case it doesn't write that to the page and in the other is writes it as FrontPage_Form2.

Any suggestions what Might be wrong?

NEW.ASP code
<%IF request.form("oem_build_accepted") = "Yes" OR request.form("oem_build_accepted") = "No" THEN%>
<form METHOD="POST" action="insert.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1" language="JavaScript">
<%ELSE%>
<form METHOD="POST" action="new.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1" language="JavaScript">
<%END IF%>




When request.form("oem_build_accepted") IS NOT equal to Yes or No it writes
<form METHOD="POST" action="new.asp" onsubmit="return FrontPage_Form2_Validator(this)" name="FrontPage_Form2" language="JavaScript">


When request.form("oem_build_accepted") equals Yes or No it writes
<form METHOD="POST" action="insert.asp" language="JavaScript">

(in reply to and13345)
rdouglass

 

Posts: 9227
From: Biddeford, ME USA
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 10:37:39   
Is this inside a DRW? You may need to put it on a Spooky DIet.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to and13345)
and13345

 

Posts: 99
Joined: 10/7/2003
Status: offline

 
RE: Using OnChange to post form back to itself - 11/18/2005 11:06:56   
No, it is not a DRW. It was a form created with FrontPage so it had a bunch of webbot validation and such. I went through and removed all the FP generated validation and that didn't make any difference either.

I have change the way I generate the FORM header. I am now using response.write to generate it and it seems to be working now.

<%
IF request.form("oem_build_accepted") = "Yes" OR request.form("oem_build_accepted") = "No" THEN
	response.write("<form METHOD='POST' action='insert.asp' name='FrontPage_Form1'>")
ELSE
	response.write("<form METHOD='POST' action='new.asp' name='FrontPage_Form1'>")
END IF
%>

(in reply to rdouglass)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Using OnChange to post form back to itself
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts