...

View Full Version : Hidden field set onchange (2 selects)



austenozzy
12-13-2007, 06:06 PM
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>

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

zc2
12-13-2007, 11:50 PM
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";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum