Results 1 to 6 of 6

Thread: Processing 2 Form Pulldown Selections

  1. #1
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Processing 2 Form Pulldown Selections

    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.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    If you want an onclick, try this:
    Code:
    <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:
    Code:
    <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
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    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?..
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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!

  6. #6
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Here's a basic example to keep you going
    Code:
    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,
    Code:
    <input type="button" value="Submit" onclick="rangProcess()">
    Hope that helps
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

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