I am aware that there are several questions dealing with how to pass querystring to HTML page but I have not been able to find one that resolves my issue.
We have a php page called viewrecs.php. This page queries the database and returns several records including recordId. The value of this id is passed to an HTML page called edit.html as shown below:
<a href="edit.html?recid='.$row['recordId'].'">Edit</a>
I am trying to grab the value of this recordId and store it as hidden field in edit.html page.
I have tried modifying the following JavaScript that I found on this forum to solve this problem but the value of recordId comes back blank.
<script type="text/javascript">
$(document).ready(function () {
var x = getParameterByName("recid"); ///get url parameter value
alert("recid : " + x);
function getParameterByName(id) {
id = id.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + id + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
});
</script>
Then HTML:
<input type="hidden" name="recid"/>
How can I retrieve the value of the querystring from php page and passed to HTML page and store it in a hidden form field?
CREDIT: The Javascript I modified above originally belongs to Mahmoude Elghandour