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

Text Box value as parameter to hyperlink?

Status
Not open for further replies.

lingyi

Programmer
Apr 11, 2001
65
SG
Hi,
I got one text box which as for user to enter the quantity that user want. This text box will going through a loop of recordset. I named my text box as name=&quot;<%response.write &quot;Qty_&quot; & rst(&quot;ItemCode&quot; %>. Beside of the text box it will have one image. When user click on the image, it will perform a hyperlink go to another asp page. Here is the code belows:
<a href=&quot;Order_Items.asp?ItemCode=<% response.write rstFile(&quot;ItemCode&quot;) %>+&Quantity=<% response.write &quot;Qty_&quot; & rst(&quot;ItemCode&quot; %>&quot; target=&quot;mainFrame&quot;><img src=&quot;Images/addcart_icon.gif&quot; width=&quot;32&quot; height=&quot;31&quot; alt=&quot;Add to Cart&quot; border=&quot;0&quot; ></a>
The point is the Quantity parameter return me the text of the text box been named. Anyone got any idea of retrieve the value of it?
Thanks :)
 
Hello,
It seems that you again have been trapped.
I would recommend reading about DOM (document object model)
for example
for MS links are moved to

As for your code - after quantity I read the same code as you wrote for the name of the textbox.
If it was regular textbox named xyz then you will need xyz.value to have the input value. (Or longer way formName.xyz.value, or document.forms[0].elements[3].value and so on)
Try adding .value after <% %> and see if you will get the desired value of the text box.

Hope this helps.
D.
 
Hi Dianal,
The method that proposed by you is not correct, it still give me the whole text as 'formname.xyz.value'. Now I can get my value of text box in function of Javascript but then I still dont know how to pass it through my hyperlink.
Any idea?
My code now work as this way:
text box - name=&quot;<% response.write rst(&quot;ItemCode&quot;)%>&quot; ...onblur=&quot;GetValue(this);return a;&quot; --calling a jvscript function.
in my image hyperlink :
<a href=&quot;Order_Items.asp?ItemCode=<% response.write rstFile(&quot;ItemCode&quot;) %>&Quantity=a&quot; target=&quot;mainFrame&quot;><img src=&quot;Images/addcart_icon.gif&quot; width=&quot;32&quot; height=&quot;31&quot; alt=&quot;Add to Cart&quot; border=&quot;0&quot; ></a>

The value that I get from the Order_Items.asp for quantity is 'a' instead of a number
 
If you put an ID= in the <A> element you can address the element in JScript on the client side to change the HRef. Use GetElementByID then objElement.HRef =. Your <A> element is being created on the Server Side so &Quantity is doing you no good in the HRef i.e. all the Response.Write and <% %> are executed on the Server Side.
 
If u want to find the value of te textbox
try this way
<input type=&quot;text&quot; name=&quot;<%=response.write &quot;Qty_&quot; & rst(&quot;ItemCode&quot;)%> id=&quot;<%=response.write &quot;Qty_&quot; & rst(&quot;ItemCode&quot;)%> >

and for the value of this

use
if this is in a form put formName if not don't
document.all.formName.<%=response.write &quot;Qty_&quot; & rst(&quot;ItemCode&quot;)%>.value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top