Here i am fetching the value from database and showing it in a input field
and
your link is generated when the page loads therefore it will always have the original value in it. You will need to set the link via javascript
You could also just wrap that in a form and have hidden fields for id
, productid
, and unitrate
Here's a sample for ya.
HTML
click me
JS
function changeUrl(){
var url = document.getElementById("imgUpdate").getAttribute('href');
var inputValue = document.getElementById('ss').value;
var currentQ = GiveMeTheQueryStringParameterValue("quantity",url);
url = url.replace("quantity=" + currentQ, "quantity=" + inputValue);
document.getElementById("imgUpdate").setAttribute('href',url)
}
function GiveMeTheQueryStringParameterValue(parameterName, input) {
parameterName = parameterName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + parameterName + "=([^]*)");
var results = regex.exec(input);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
this could be cleaned up and expanded as you need it but the example works