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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading value from combobox

Status
Not open for further replies.

softjack

Programmer
Dec 4, 2005
44
IN
Hi

I have a combobox and i successfully retrieve some value in it from database.

Now i have a menu designed using javascript. So when i click on this menu, i want to retrieve the selected value in that combo box and pass it to another jsp page.
How can i do that

my combo box name is 'dtr'

Need to get it here somehow
Code:
<LI><A href="Getdata2.jsp?TFCode1=<%= comboboxvalue %>">View Details </A>

Please help me as this is urgent1

Thanks
Softjack
 
Once the page is drawn, all your embedded Java code is converted to HTML/JavaScript. If you need the current value of the combobox, I would recommend:
Code:
<LI><A href="[red]javascript:void(0)[/red]" [red]onclick='getdata2(this.form)'[/red]>View Details </A>
..and then writing a javascript function to define the address you want to go to as such:
Code:
<script>
function getdata2(formObj)
{
 var val = formObj.myComboBox.value;
 document.location = "Getdata2.jsp?TFCode1="+val;
}
</script>

In the event that an anchor tag does not recognize "this.form", you can replace with "document.forms[0]".

Either way, this requires your users to have JavaScript enabled.

If you can't count on JavaScript being enabled, then you might consider changing the link to a Submit button with the action of your form being set to "Getdata2.jsp". This will send form values to the target JSP (including your combobox value).

...or am I misunderstanding your question?

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top