Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    variable addition :: onSubmit

    age field value number is from form1, and was sent to form2 via the url. I've decoded the url and used document.write to display the number on the page of form2.

    I'm having a problem adding age number(from form1) to edu number value selection, from form2, to get a non cancatenated(sp?) number, like 4+5=9, NOT 4+5=45
    this is what i've been working on, with many troubles and hardships, i was wondering is someone could ease the pain?:

    <form name="form2" action="Occupational_Demand.htm" method="GET" onsubmit=var sum = parseInt(document.form1.age.value)+parseInt(document.form2.edu.options[document.form2.edu.selectedIndex].value);
    document.location="Occupational_Demand.htm?edu="+sum">

    the goal is to add the numbers and send them via url to the next form, but so far no luck. I don't want to stray from what i have; to use hidden fields, or use fames. Thanks

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Pleae do help, maybe my wording is poor, lets see......

    passed value from form1 to form2 via url. code below is on form2 to send to form3 (Occupational_Demand.htm). Why is this not working, only form2 value is being passed via url to form3, not the summation of form1 and form2 values, like 4+5=9, 9 passed to form3

    <form name="form2" action="Occupational_Demand.htm" method="GET" onSubmit="document.location="Occupational_Demand.htm?edu="+(parseInt(document.form1.age.value)+parse Int(document.form2.edu.value))";>

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If form1 is on your first page and you had to get it's value from a URL then you can't be getting it's value directly from the form as you try to pass it onto form3. In short document.form1.age.value isn't available, you need to use the field you stored in into on form2 instead.

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply i got it working:


    var sStr = document.location.search;
    var val = parseInt(sStr.substring(sStr.indexOf("=")+1,sStr.indexOf(",")));
    var sum = parseInt(document.f2.edu[j].value)+((!isNaN(val))?val:0);
    if(itemchecked){
    data = sStr.substring(sStr.indexOf(","),sStr.length)+ ",(edu="+parseInt(document.f2.edu[j].value)+")";
    document.f2.action="Occupational_Demand.htm?edu="+sum+data ;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •