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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hidden field set onchange (2 selects)

    Hi there,

    I have a form with some questions in it, with the answers in select menus.

    I have two possible 'thanks' pages: 'enterprise' and 'express'. There is a hidden field which should contain one of those values.

    There are a couple of conditions where the answers should set the value to 'express'; otherwise, they will all be 'enterprise'.

    The function is called by an onChange in the third of the three select menus.

    Here's the code that isn't currently working :-(

    Any help greatly appreciated.

    Oz.

    ----------------------------

    <script language="javascript" type="text/javascript">

    function ftswitch()
    {

    var wizardQ1 = document.getElementById("wizardQ1").value;
    switch (wizardQ1)
    {
    case "Fewer than 10":
    q1="express";
    break
    case "10 to 100":
    q1="express";
    break
    default:
    q1="enterprise";
    }

    var wizardQ3 = document.getElementById("wizardQ3").value;
    switch (wizardQ3)
    {
    case "Less than 5k":
    q3="express";
    break
    case "5 to 25k":
    q3="express";
    break
    default:
    q3="enterprise";
    }

    if (q1 = express)
    {
    document.write("<input type=hidden name=ok_url value=http://www.domain.com/express>");
    }
    else if (q3 = express)
    {
    document.write("<input type=hidden name=ok_url value=http://www.domain.com/express>");
    }
    else
    {
    document.write("<input type=hidden name=ok_url value=http://www.domain.com/enterprise>");
    }
    }

    </script>

    ----------------------

  • #2
    zc2
    zc2 is offline
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why do you need to create the hidden field onchange?
    why not just change its value?
    like this:
    if (q1 == "express") // your code is wrong here, you need a comparative operator '==' not '='
    {
    document.getElementById("ok_url").value="http://www.domain.com/express";
    }


  •  

    Posting Permissions

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