I want to pass the value of input tag as parameter(quantita) in href. Should i use javascript to do this?Sorry for my english Thanks
<input type="text" id="qta_field" value="${item.value}"/><a href="updateItem?codice=${item.key.codice}&quantita=">update</a>
You need add quotes for your href , besides, you also need to use urlencode to encode the variable. . '">$compname</a>" ?? The last " should be a ' instead.
href”, append the variable to it (Here we have used a variable named “XYZ”). Then we need to append the value to the URL. Now our URL is ready with the variable and its value appended to it. In the example below, we will append a variable named 'XYZ' and its value is 55.
getElementById('someDiv'); // create <a> tag var tag = document. createElement(a); // set the href attribute tag. setAttribute('href', exampleHref); // append the node to the parent div. appendChild(tag);
The HTML Anchor Link will be assigned an OnClick event handler and when clicked, the value of the TextBox will be set in the HREF attribute of the HTML Anchor Link using JavaScript. When the HTML Anchor Link is clicked, the TextBox value will be passed to the other Page as QueryString parameter.
The easiest way to do it with link and without any library:
<input type="text" id="qta_field" value="${item.value}"/>
<a href='' onclick="this.href='updateItem?codice=${item.key.codice}&quantita='+document.getElementById('qta_field').value">update</a>
To send data from an input to the server, you should use a form.
<form action="updateItem">
<input id="qta_field" name="quantita" value="${item.value}">
<input type="hidden" name="codice" value="${item.key.codice}">
<button>update</button>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With