Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem passing data to href  RSS feed

 
Dave Lawrence
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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>
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Michael Arnett
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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>
 
Jolly Jumper
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank's for all the help, it all works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!