javascript - Get value of form text field with without submitting the form -
i have form on page , want able submit text box value (partnumber) query string in hyperlink without submitting form ? possible ? have done research , have tried document.getelementbyid("partnumber").value getting error "object required". code below.
<form id="form3" name="form3" method="post" action="formpost?rmaid=<%=rmaid%>"> <input name="partnumber" type="text" id="partnumber" size="10" /> <a href="suggest.asp?partnumber=<%document.getelementbyid("partnumber").value%>"><span class="style11">suggest link</span></a> <input name="invoice" type="text" id="invoice" size="15" /> </form>
i'll set new page open in pop window , list series of values in database need value selected come invoice field on original page. believe can done javascript new this, can ?
for looking pass values have found snippet works... put in child window
<script language="javascript"> function changeparent() { window.opener.document.getelementbyid('invoice').value="value changed.."; window.close(); } </script> <form> <input type=button onclick="javascript:changeparent()" value="change opener's textbox's value.."> </form>
for input field should add onchange it. event should call function set link's value.
you can see example of here (it uses button press though , not input onchange event): http://www.java2s.com/code/javascript/html/changeurlandtextofahyperlink.htm
edit: added stack snippet illustrating solution.
function setsuggestlink() { var suggest = document.getelementbyid('partnumber').value; document.getelementbyid('innerspan').innerhtml = "suggest link: suggest.asp?partnumber=" + suggest; document.getelementbyid('querylink').href = "suggest.asp?partnumber=" + suggest; }
.style11 { color:black; } .style2 { text-decoration:none; }
<form id="form3" name="form3" method="post" action="formpost?rmaid=somevalue"> <input name="partnumber" type="text" id="partnumber" size="10" onchange="setsuggestlink()" /> </br> <a id="querylink" class="style2" href="#"> <span id="innerspan" class="style11">suggest link</span> </a></br> <input name="invoice" type="text" id="invoice" size="15" /> </form>
Comments
Post a Comment