Results 1 to 5 of 5

Thread: Very simple javascript...

  1. #1

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Unhappy Very simple javascript...

    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.
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Very simple javascript...

    Quote Originally Posted by AvisSoft
    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:

    Code:
    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
    My Blog.

    Ryan Jones.

  3. #3

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Re: Very simple javascript...

    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
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Very simple javascript...

    Quote Originally Posted by AvisSoft
    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:

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

    RyanJ
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Re: Very simple javascript...

    Hi,

    Thanks it helped.

    Thanks again.
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

Posting Permissions

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



Click Here to Expand Forum to Full Width