PDA

Click to See Complete Forum and Search --> : Very simple javascript...


AvisSoft
May 25th, 2005, 09:54 AM
Hello,

I have a dropdown name poems in which several poems are listed. And i have a href link now what i am trying to do is whenever the href link is clicked the value of the dropdown should get added to href link. For example:

link is: eg.php?poem=

upon clicking it should become eg.php?poem=x

where x is the value of the selected dropdown option. How can i do this ?

Thanks.

sciguyryan
May 25th, 2005, 10:07 AM
Hello,

I have a dropdown name poems in which several poems are listed. And i have a href link now what i am trying to do is whenever the href link is clicked the value of the dropdown should get added to href link. For example:

link is: eg.php?poem=

upon clicking it should become eg.php?poem=x

where x is the value of the selected dropdown option. How can i do this ?

Thanks.

Try this:


var MyDropdown = document.getElementById("Your Dropdown Menus ID Here");
var TheString = MyDropdown.options[MyDropdown.selectedIndex].text;
window.location.href = New String("eg.php?poem=x" + TheString);


Cheers,

RyanJ

AvisSoft
May 25th, 2005, 10:53 AM
Hi,

Thanks for the solutons but i need to get solution like this in just 1 line:

var pid = document.f1.poemid.selectedIndex; (this is not working)

Thanks

sciguyryan
May 25th, 2005, 10:58 AM
Hi,

Thanks for the solutons but i need to get solution like this in just 1 line:

var pid = document.f1.poemid.selectedIndex; (this is not working)

Thanks


You can put the code I gave you in one line:


var TheString = document.f1.poemid.options[document.f1.poemid.selectedIndex].value;
window.location.href = New String("eg.php?poem=x" + TheString);


Cheers,

RyanJ

AvisSoft
May 25th, 2005, 11:54 AM
Hi,

Thanks it helped.

Thanks again.