/    Sign up×
Community /Pin to ProfileBookmark

variable summation onSubmit

a field passed and written to this form, from a previous form:
var loc=””+document.location;
loc = loc.indexOf(“?age=”)!=-1?loc.substring(loc.indexOf(“?age=”)+5,loc.length):””;
var age = loc.indexOf(“&”)!=-1?loc.substring(0,loc.indexOf(“&”)):loc;
document.write(age);

problem lyes in adding age and new form selection value with the previous form selection (age) onsubmit:
<form name=”f2″ action=”Occupational_Demand.htm” method=”GET” onSubmit=”var sum = parseInt(document.f1.age.value)+parseInt(document.f2.edu.options[document.f2.edu.selectedIndex].value);
document.location=”Occupational_Demand.htm?edu=”+sum”>

thanks for your input! much appreciated

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Jan 19.2003 — put all of your code here

may be a zipped file

Khalid
Copy linkTweet thisAlerts:
@catchupauthorJan 19.2003 — The problem is on the second form submitting to the 3rd, they are all inter joined, the first form post using the GET method to this page:

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Education</title>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function checkRadios() {

var el = document.forms[0].elements;

for(var i = 0 ; i < el.length ; ++i) {

if(el[i].type == "radio") {

var radiogroup = el[el[i].name]; // get the whole set of radio buttons.

var itemchecked = false;

for(var j = 0 ; j < radiogroup.length ; ++j) {

if(radiogroup[j].checked) {

itemchecked = true;

break;

}

}

if(!itemchecked) {

alert("Please select an Education Level");

if(el[i].focus)

el[i].focus();

return false;

}

}

}

return true;

}

// End -->

</script>



</head>



<body>



<p align="center"><font face="Arial, Helvetica, sans-serif" color="#000099" size="+1"><b>Skilled

Worker Self-Assessment</b></font>

<p align="center"><font face="Arial, Helvetica, sans-serif" color="#000099"><b>Factor

2 - Education&nbsp;</b> <font size="-1">(maximum 20 points)</font></font></p>

<p align="center">

<font face="Arial,Helvetica,sans-serif" size="-1">Your score up to this

point is:&nbsp;</font><SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var loc=""+document.location;

loc = loc.indexOf("?age=")!=-1?loc.substring(loc.indexOf("?age=")+5,loc.length):"";

var age = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;

document.write(age);

// End -->

</script></p>

<p ALIGN="left" style="text-indent: 0; line-height: 100%">The principal applicant’s highest

level of education:<br>

(<a href="Education_Definitions.htm">Click for definitions of various education

levels</a>.)<!-- FORM STARTS HERE -->

</p>

<form name="f2" action="Occupational_Demand.htm" method="GET" onSubmit="return checkRadios(this)","var sum = parseInt(document.f1.age.value)+parseInt(document.f2.edu.options[document.f2.edu.selectedIndex].value);

document.location="Occupational_Demand.htm?edu='+sum'">

<table cellSpacing="10" cellPadding="0" width="662" border="0">

<tbody>

<tr>

<td align="left" width="604">

<div align="left">

<font face="Times New Roman" size="3">I have a second or third level university degree (e.g., masters or doctorate)</font>

</div>

</td>

<td align="left" width="28"><font size="-1"><input type="radio" value="20" name="edu"></font></td>

</tr>

<tr>

<td align="left" width="604">

<div align="left">

<font face="Times New Roman" size="3">I have a university degree or a diploma that required at least three (3) years of full time post-secondary study&nbsp;

OR&nbsp; I have an apprenticeship or a trade certificate based on at least three (3) years of combined education and on-the-job training.</font>

</div>

</td>

<td align="left" width="28"><font size="-1"><input type="radio" value="16" name="edu"></font></td>

</tr>

<tr>

<td align="left" width="604">

<div align="left">

<font face="Times New Roman" size="3">I have completed a 1 to 2 year post-secondary program.</font>

</div>

</td>

<td align="left" width="28"><font size="-1"><input type="radio" value="14" name="edu"></font></td>

</tr>

<tr>

<td align="left" width="604">

<div align="left">

<font face="Times New Roman" size="3">I have completed secondary school (high school).</font>

</div>

</td>

<td align="left" width="28"><font size="-1"><input type="radio" value="10" name="edu"></font></td>

</tr>

<tr>

<td align="left" width="604">

<div align="left">

<font face="Times New Roman" size="3">I have not completed secondary school.</font>

</div>

</td>

<td align="left" width="28"><font size="-1"><input type="radio" value="0" name="edu"></font></td>

</tr>

</tbody>

</table>

<p><input type="submit" value="Next">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="Clear" name="Reset"></p>

</form>

</body>

</html>

Copy linkTweet thisAlerts:
@catchupauthorJan 20.2003 — PLease....
Copy linkTweet thisAlerts:
@khalidali63Jan 20.2003 — I have made several changes to make your code work and properly as required.

Please see the attached zip file

cheers

Khalid

[upl-file uuid=bd058ffe-8ccb-46c4-9345-4cda718fb7e2 size=6kB]catchup-forwarddata.zip[/upl-file]
Copy linkTweet thisAlerts:
@catchupauthorJan 20.2003 — Dude, i read it and it seem to want to work, but when i tried it, the same problem as i had b4, the summations don't add and go to the next form????
Copy linkTweet thisAlerts:
@catchupauthorJan 20.2003 — My apologies, it workes on the desktop on my computer but not on the web when i ftp.... why would this be? hmmm......
Copy linkTweet thisAlerts:
@khalidali63Jan 20.2003 — you should be able to do that with pety

simple functionality.

Anyways,

I have attached an updated zip file for you.

try it.

Khalid

[upl-file uuid=f62e4079-0b77-4911-9727-8b78e2be2cf1 size=7kB]catchup-forwarddata.zip[/upl-file]
Copy linkTweet thisAlerts:
@khalidali63Jan 20.2003 — you might want to make sure that the URL location actually is a valid one,since a web browser might read relative url paths differently as compare to the absolute.

Khalid
Copy linkTweet thisAlerts:
@catchupauthorJan 20.2003 — U R GOD, and its scaring me, besides im in winnipeg and even though its a good 16 hours away i can still feel your power. cheers
Copy linkTweet thisAlerts:
@catchupauthorJan 20.2003 — 1 other thing if you wouldn't mind, I displaying the field values from the previous form, like so:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var loc=""+document.location;

loc = loc.indexOf("?age=")!=-1?loc.substring(loc.indexOf("?age=")+5,loc.length):"";

var age = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;

document.write(age);

// End -->

</script>

so on the second form, the first form field value is displayed, and on the the third form, the second fields value, and so forth, but now its picking up the data = sStr.substring(sStr.indexOf(","),sStr.length)+ ",(edu="+parseInt(document.f2.edu[j].value)+")";

like so: Your score up to this point is: 10,(age=10)

how can this be changed so that it only reads: Your score up to this point is: 10

thanks again.
Copy linkTweet thisAlerts:
@khalidali63Jan 20.2003 — do you mean that at any given page it should print phrase

:Your score before completing this page = X;

?

Khalid
Copy linkTweet thisAlerts:
@khalidali63Jan 20.2003 — Here you go

Khalid

[upl-file uuid=011245d1-ff85-4221-9dfb-28ba881d90f0 size=8kB]catchup-forwarddata.zip[/upl-file]
×

Success!

Help @catchup spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...