Click to See Complete Forum and Search --> : setting up a value


rjusa
10-29-2003, 07:56 AM
What I am trying to do is write a script that on a onClick command will set the value of "next_page" to the appropriate choice. The code I tried is a follows:

<SCRIPT>
function SetNextPage1() {
form.next_page.value="Canadian_supp10";
return 0;
}
</SCRIPT>

<SCRIPT>
function SetNextPage2() {
form.next_page.value="MedAdv_LifeStyle";
return 0;
}
</SCRIPT>

<input type=hidden name="next_page" value="">

<input type="radio" name="IFAC" value="Yes" $IFAC_Yes_checked$ onClick="SetNextPage1">
<input type="radio" name="IFAC" value="No" $IFAC_No_checked$ onClick="SetNextPage2">

Any help would be appreciated. Thanks.

Ron

requestcode
10-29-2003, 08:36 AM
This should work.
<SCRIPT>
function SetNextPage(nextpage) {
document.myform.next_page.value=nextpage;
return 0;
}
</SCRIPT>

<form name="myform">
<input type=hidden name="next_page" value="">

<input type="radio" name="IFAC" value="Yes" $IFAC_Yes_checked$ onClick="SetNextPage('Canadian_supp10')">
<input type="radio" name="IFAC" value="No" $IFAC_No_checked$ onClick="SetNextPage('MedAdv_LifeStyle')">
</form>

I changed it to use one script and to pass the value to the function. If you can't use the form name or don't have one then you can change this line:
document.myform.next_page.value=nextpage;
To this:
document.forms[0].next_page.value=nextpage;

"forms[0]" refers to the first form in your document. If you have more than one form and this is the second form in the document then it would be "forms[1]".

rjusa
10-29-2003, 09:12 AM
Really appreciate your help. Well, I'm a lot closer than I was. When I edit the code and click Submit I get "the form page you requested is not available." Figuring maybe I somehow deleted the 2 forms I went in and hard coded the value="" to Canadian_supp10 and then MedAdv_LifeStyle. When I clicked Submit it took me to the correct forms. So obviously, somehow the reference isn't correct. Any thoughts?

Thanks,
Ron

requestcode
10-29-2003, 09:27 AM
Can you give us a link to the code? It would help if I could see the whole thing.

rjusa
10-29-2003, 09:31 AM
http://hamptoninsurance.com/forms/forms.cgi?form=22

requestcode
10-29-2003, 09:57 AM
Ok I see your problem. Your "FORM" tag does not have a name property, but your script statement is referring to a form named "myform". I used that as an example as I did not know if you have a form name or not. Try changing this line:
document.myform.next_page.value=nextpage;

To this:
document.forms[0].next_page.value=nextpage;

rjusa
10-29-2003, 10:17 AM
We're 50% there! When I click "Yes" and then "Submit" I'm taken to the correct form...neat...thanks...however, if I click "No" and then "Submit" nothing happens...now what oh wise one?

Thanks,
Ron

rjusa
10-29-2003, 10:41 AM
OK, so I'm an idiot!!! Somehow, perhaps at 3:30 AM, I replaced the MedAdv_LifeStyle form with the current form we're working from, i.e., ValueChanger...once I discovered this and uploaded the correct version of MedAdv_LifeStyle life became good again. Thanks for all your help. One of the trickiest parts of this exercise was trying to pass back from child window to parent the value of a radio button selection...an individual in Canada helped me with this one and it was pretty tricky...passing values of an array...if anyone needs help with this I'd be glad to share the answer...it's the least I can do. Again, thanks!!!

Ron