It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Javascripts open a page based on dynamic dropdown values

Javascripts open a page based on dynamic dropdown values

Postby atwebpr2 on Wed Mar 16, 2011 7:23 am

Hi everybody,

I have got a form in a page that contains 2 dynamic dropdowns controls. The selection of a value included in the first dropdown will determine the content appearing on the second one. The structure is something like this:
Code: Select all
<div >
    <select name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
    <option value=" ">Select</option>
    <option value="1">Mr</option>
    <option value="2">Mrs</option>
    <option value="3">Miss</option>
    </select>
</div>

<div>
    <select name="opttwo" size="1">
    <option value="" selected ="selected">Please select one of the options above first</option>
    </select>
</div>

<div>
    <input type="button" name="go" value="Value Selected" onclick="open(document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value);">
</div>


What I am trying to do is to open a determined page based on the values selected from the dropdown controls previously chosen. At the moment I am trying to do that with a "onClick" event on the button that will then launch whatever value is included for the selection of the dropdown. the javascripts the attribute this values is the following:
Code: Select all
function setOptions(chosen)
{
var selbox = document.myform.opttwo;
selbox.options.length = 0;
   if (chosen == " ") {
     selbox.options[selbox.options.length] = new Option('Please select one of the options on the left first','Select from control next');   
   }
   if (chosen == "1") {
     selbox.options[selbox.options.length] = new Option('Accounting','www.google.com');
     selbox.options[selbox.options.length] = new Option('Tax return','www.yahoo.com');
   }
   if (chosen == "2") {
     selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
     selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
   }
   if (chosen == "3") {
     selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
     selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
   }
}


Assuming that this form is in my homepage like "mysite.com", what I would like to achieve is to open pne of the subpage of my site following the method described above.

I hope I have been managed to be clear enough.

Regards,
Antonio
atwebpr2
 
Posts: 1
Joined: Wed Mar 16, 2011 7:09 am

Who is online

Users browsing this forum: No registered users and 9 guests