View Full Version : Modify script from checkbox to pulldown.


Kathy
04-14-2005, 04:54 PM
Hi All,

I have a javascript that will modify the URL of a form on-the-fly based on a checkbox or radio button.

I am wanting to modify it to change the URL based on a pull down menu instead.

I do not know much about JavaScript. Does anyone know if there is an inherent reason this will not work.

Also any pointers would be greatly appreciated!

This is the code I have now.


<script type="text/javascript" language="JavaScript">
<!--
function ActionDeterminator()
{
if(document.myform.reason[0].checked == true) {
document.myform.action = '/cgi-bin/mf1.cgi';
}
if(document.myform.reason[1].checked == true) {
document.myform.action = '/cgi-bin/mf2.cgi';
document.myform.method = 'get';
}
if(document.myform.reason[2].checked == true) {
document.myform.action = 'http://yahoo.com';
}
return true;
}
// -->
</script>

<form name="myform" method="post" action="/cgi-bin/mf.cgi">
Name: <input type="text" name="a name" size="22"><br>
Email: <input type="text" name="email"size="22"><br>
Reason:<br>
<input type="radio" name="reason">I have a Hot Tip!<br>
<input type="radio" name="reason">I saw a Cool Site!<br>
<input type="radio" name="reason">Get me outta here!<br>
Type comment here:<br>
<textarea name="comments" cols="27" rows="6">
</textarea><br><br>
<input
type="submit"
value="Send It!"
onClick="return ActionDeterminator();">
</form>

SEO Aaron
05-12-2005, 09:47 AM
<script type="text/javascript" language="JavaScript">
<!--
function ActionDeterminator()
{
choice = document.myform.pizza.selectedIndex
if(document.myform.pizza.options[choice].value == "HotTip") {
document.myform.action = '/cgi-bin/mf1.cgi';
}
if(document.myform.pizza.options[choice].value == "CoolSite") {
document.myform.action = '/cgi-bin/mf2.cgi';
document.myform.method = 'get';
}
if(document.myform.pizza.options[choice].value == "outaHere") {
document.myform.action = 'http://yahoo.com';
}
return true;
}
// -->
</script>

<form name="myform" method="post" action="/cgi-bin/mf.cgi">
Name: <input type="text" name="a name" size="22"><br>
Email: <input type="text" name="email"size="22"><br>
Reason:<br>
<select name="pizza">
<option name="reason" value="HotTip">I have a Hot Tip!</option>
<option name="reason" value="CoolSite">I saw a Cool Site!</option>
<option name="reason" value="outaHere">Get me outta here!</option>
</select>
<br>Type comment here:<br>
<textarea name="comments" cols="27" rows="6">
</textarea><br><br>
<input
type="submit"
value="Send It!"
onClick="return ActionDeterminator();">
</form>


This code makes a drop down box version. :-)

Aaron

Liyrhsara
03-11-2007, 07:16 PM
Hello there! These sites are your source for fast software downloads: Download AutoCAD Software Safe (http://autocad-software.teracities.com) Download Lynda.Com Tutorials (http://lynda-com.free-site-host.com) Download Macromedia Software (http://macromedia.icspace.net) Download OEM After Effects Software (http://ater-effects.ifastnet.com) Download Allien Skin OEM (http://allien-skin.ifastnet.com) Download OEM InstallShield (http://installshield.ifastnet.com) Have a nice day!