• 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

Problem passing data to href

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I would like to pass data to a hyperlink in the following code,
instead of putting the href command in the form tag.
How can I get the value in orderno into this request.
<html>
<head>
<title> Order Entry </title>
</head>
<form>
<center>
<p>
Order Number:<input name="orderno" title="Order Num"/>
</p>
<a href="http://10.11.12.134:7891/ServletName?OrderNo=orderno">Get Order</a>
</form>
</html>
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<a href="http://10.11.12.134:7891/ServletName?OrderNo=<%= orderno %>">Get Order</a>
This assumes that "orderno" is a Java variable that converts to a String object.
 
Dave Lawrence
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
thanks for the reply.
How do you get the html input orderno into a java String
so that I can pass it in the url call.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this would be best accomplished by using javascript. I'm not sure off the top of my head how to do it, but try to add an onclick event to an image or text or whatever and then forward the page from that function...
Try something like:
<input name="testin">
<a name="jumper" href = "http://javaranch.com" onclick="jumper.href = 'http://'+ testin.value">Make go now!</a>
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Check it.
<html>
<head>
<title> Order Entry </title>
</head>
<form>
<center>
<p>
Order Number:<input name="orderno" title="Order Num"/>
</p>
<a onClick="location.href='http://10.11.12.134:7891/ServletName?OrderNo=' + document.forms[0].orderno.value; return false;" href="">Get Order</a>
</form>
</html>
If you'd like to open your target in a new window, use window.open(...) instead.
 
Dave Lawrence
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's for all the help, it all works.
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic