I have an issue in getting value from url, I have a link which shows up a modal as I have
<a href='#modal?userId=<%=resultSet.getInt("drid")%>' class="button-border toggleModal">Apportionment</a>
above link opens up the modal is given below
<div id="modal" class="modal">
<header>
<h2>Appointment Form</h2>
</header>
<form action="addappoinment.jsp" method="post">
<input type="hidden" id="docId" name="docid" value=""><br>
<input type="text" required><br>
<input type="text" required><br>
<input type="text" required><br>
<input type="text" required><br>
<textarea rows="4" cols="21"></textarea><br>
<button class="button-border button-success" type="submit">
Done</button>
<button class="button-border button-error pull-right toggleModal">
Cancel</button>
</form>
</div>
Now I have a url like
http://localhost:8080/app/#modal?userId=1
now I want to get value of userId
parameter using the javascript
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var param = getParameterByName("userId");
var userId = document.getElementById("docId");
userId.value = param;
</script>
but can not be able to get value from http://localhost:8080/app/#modal?userId=1