Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing list value in a hyperlink

Status
Not open for further replies.

nivone

Programmer
Jul 2, 2002
33
IL
HI,

I have a form that includes (among other stuff) a drop down list box that includes a list of people and a hyperlink called "details".
I want that once the "details" hyperlink is clicked, it will pass the item selected in the list to a Perl script, for example:
../cgi-bin/script.pl?itemselected.
How do I build this hyperlink?

Thanks
 
Your link will need to look something like this though you will have to change the formname and selectname for those in you page...
Code:
<a href=&quot;#&quot; onclick=&quot;document.location.href='../cgi-bin/script.pl?itemselected='+document.formname.selectname.options[document.formname.selectname.selectedIndex].value; return false;&quot;>TheLink</a>

hope this helps...

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
HI,

Almost...
I get an empty value.
The drop down list has a value and I get no JS errors.
 
create a javascript function to check if your page manage to get the list value before you call the perl script. sometimes it is because you are passing empty value. another precaution of using link to pass value is that your value mustn't have '?' and '&' as this 2 are special character in the link passing.
 
HI,

It seems that I have a problem only with a drop down menu.
When I try the same with text area and text box it works fine.
 
use javascript to get the drop down value and it should solve your problem.
 
HI,

Well, this is why I started this thread. How do I get it and put it in a hyperlink?
 
It's working now. I switched the .value with .text
Thanks crazyboybert
 
Hi Nivone

What happened is this. WEhen you have an option element in the select list it has 2 readable properties, .value and .text

.value - this is the 'value' attribute as specified in the tag

.text - this is the displayed text shown in the select list between the opening and closing tags of the option

<option value=&quot;value&quot;>text</option>

this allows you to have a different display value to that which you pass on from the form...can be very handy.

:)




------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top