Passing parameter to page using Javascript
This is an example method using javascript to redirect to the searching page with a parameter from the textbox when click the submits button.
Requirement
- JQuery library
HTML
<div class="input-group search-btn">
<input id="textSearch" type="text" onkeypress="keypressSearch(e);" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" onclick="return Search();return false;" type="button">SEARCH</button>
</span>
</div>
Javascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
function Search() {
var txtField = jQuery("#textSearch").val();
document.location.href = "/Search.aspx?searchtext=" + txtField + "&searchmode=anyword";
return false;
}
function keypressSearch(event) {
if (event.keyCode == 13) {
Search();
return false;
}
else {
}
}
</script>