PDA

View Full Version : Processing 2 Form Pulldown Selections



svoltmer
04-17-2008, 06:28 PM
I am trying, using a form with 2 pulldown selections (month and day of the month), to have the user navigate to the corresponding url for that particular month and day of the month. I don't know much javascript either. Any help would be appreciated! Thanks!

Here is my site:
http://www.crosst.org/test/index.html

you will notice the pulldowns on the lower right side of the page.

rangana
04-18-2008, 01:23 AM
If you want an onclick, try this:


<html>
<head>
<script type="text/javascript">
var rang;
window.onload=function()
{
rang=document.forms[0];
rang[1].onclick=function()
{
process(rang[0].options[rang[0].selectedIndex].value);
}
}

function process(url)
{
location.href=url;
}
</script>

</head>
<body>
<form name="form1"><select
style="background-color: transparent; font-size: 10px; color:#222; font-family: verdana;"
name="menu">
<option value="#">Quick Links</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.dynamicdrive.com/forums">Forums</option>
</select>
<input style="font-size: 8px; color: rgb(255, 255, 255); font-family: verdana; background-color: #333;"
onclick="document.location.href=document.form1.menu.options[document.form1.menu.selectedIndex].value;"
value="GO" type="button">
</form>
</body>
</html>


...If you want an onchange.. use this:


<html>
<head>
<script type="text/javascript">
var rang;
window.onload=function()
{
rang=document.forms[0];
rang[0].onchange=function()
{
process(this.value);
}
}

function process(url)
{
location.href=url;
}
</script>

</head>
<body>
<form name="form1"><select
style="background-color: transparent; font-size: 10px; color:#222; font-family: verdana;"
name="menu">
<option value="#">Quick Links</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.dynamicdrive.com/forums">Forums</option>
</select>
</form>
</body>
</html>


See if it helps :)

svoltmer
04-21-2008, 12:52 PM
Thanks, but that isn't quite what I need. I need some script to process the result of 2 selections from 2 separate pulldown options within one form. With the result navigating the user to the corresponding webpage. Any ideas?

rangana
04-21-2008, 11:57 PM
What you've got so far??...I'm confused on what you wanted to achieve...the examples i've given could have help you going :)

...Anyway, which options are you referring?...Is it the month pull down in your webpage?..

svoltmer
04-27-2008, 11:51 AM
Sorry, I already have the code to display the month and the day of the month in 2 separate pulldown selections on the right side of the web page here: htpp://www.crosst.org/test/index.html.

What I need is a way to take the results from the 2 individual pull downs and combine them into way to on submit go to a corresponding web page for that selected month and day of the month. Thanks for your help!

rangana
04-29-2008, 12:49 AM
Here's a basic example to keep you going ;)


function rangProcess()
{
var date=document.getElementById('daydropdown');
var month=document.getElementById('monthdropdown');
var baseLink="http://www.crosst.org/test/";
alert('You\'ll be directed to:' +baseLink+date.value+'/'+month.value);
location.href=baseLink+date.value+'/'+month.value;
}


...Then add another button for your submit,


<input type="button" value="Submit" onclick="rangProcess()">


Hope that helps :)