Click to See Complete Forum and Search --> : passing variables from 1 form to the next


rjusa
12-02-2003, 09:28 AM
this is a bit frustrating on 4 hrs. sleep but here goes: I have a series of forms...input value in 1st form, successfully gets passed to the second with this alert scheme

function sum(objRef) {
var result = 0;
result += document.PB2.PercentPB1.value - 0;
result += document.PB2.PercentPB2.value - 0;
if (result > 100)
alert("Your total percent allocation exceeds 100%...please check your percent distributions\nFirst Primary: " + $PercentPB1$ +"%");
if (result > 100)
document.PB2.PercentPB2.value="";}

when I go to pass values from the 2nd form to the 3rd the alert scheme doesn't work...to make sure the values from 1 & 2 were getting passed I put in temporary text boxes and the little buggers do show up...the 3rd form is named correctly (SB1) and the alert code is as follows:

function sum(objRef) {
var result = 0;
result += document.SB1.PercentPB1.value - 0;
result += document.SB1.PercentPB2.value - 0;
result += document.SB1.PercentSB1.value - 0;

if (result > 100)
alert("Your total percent allocation exceeds 100%...please check your percent distributions
\nFirst Primary: " + $PercentPB1$ +"%" + "\nSecond Primary: " + $PercentPB2$ +"%");
if (result > 100)
document.SB1.PercentSB1.value="";
}

OK, where did I screw this one up? Help please!

Thanks,
Ron

Gollum
12-02-2003, 09:45 AM
Without seeing the whole page source, it's a little difficult to say with certainty what is going wrong. But I'll hazard a guess anyway :D

Are these forms on the same html page?
If they are then you can refer to input fields directly...

var result = 0;
result += document.PB1.PercentPB1.value - 0;
result += document.PB2.PercentPB2.value - 0;
result += document.SB1.PercentSB1.value - 0;

If not, then you need to submit the value back to the server and have the server include it on the next form as a hidden.

rjusa
12-02-2003, 10:35 AM
Gollum,

Thanks for the reply...you're going to laugh (I cried!)...my statement

if (result > 100)
alert("Your total percent allocation exceeds 100%...please check your percent distributions
\nFirst Primary: " + $PercentPB1$ +"%" + "\nSecond Primary: " + $PercentPB2$ +"%");
if (result > 100)
document.SB1.PercentSB1.value="";

was screwed up...corrected it to be

if (result > 100)
alert("Your total percent allocation exceeds 100%...please review your percent distributions \n First Primary: " + "....... " + $PercentPB1$ +"%\n" + "Second Primary: " + "... " +$PercentPB2$ +"%");
if (result > 100)
document.SB1.PercentSB1.value="";

...had to do where I inserted the '\n' sequence...ah, live and learn! Thanks again.

Ron