• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get the form value

 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai


In my application i need to pass some of my form values with the html:link,i mean i will select a value from my combobox i need to pass that value also with the html:link .How can i do that?

Thanks in Advance
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you want to change the value of a link based on what the user selects before clicking on the link, you must do this on the client side, not the server side, which means you must use javaScript.

The first thing you need to do is specify styleId="xxx" in your <html:link> tag where xxx is some unique identifier. This will make it easier to access the tag in javaScript.

You will next need to retrieve the href property of this object and change it according to your needs. The best place to do this would be in the onchange event of the combo box.

Supposing you wanted to append the value of the combo box as a parameter to the URL of the link, here's some sample code:

<script>
function changeHref(optionValue) {
var link = document.getElementById('myLink');
link.href = link.href + '?option=' + optionValue;
}
</script>

<html:link styleId="myLink" action="/myAction" />
<html:select property="mySelect" onchange="changeHref(this.value);">

This is a bit simplified. In the real function, you'd want to insert code to remove the ?option parameter from the href string before adding it. This would allow for the case of the user selecting first one option, then changing her mind and selecting another.
[ January 31, 2006: Message edited by: Merrill Higginson ]
 
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic