Reputation: 4745
The original URL is http://mysite.com/locations.aspx When someone clicks on Locations link somewhere and come to this page, on page load, i want the URl to appended as follows on the fly? The Hospital is a checkbox on the page which needs to be checked by default. So when they land on the page, they see all the hospitals instead of having to check the hospital check box and reload the page. Is this possible using jquery?
http://mysite.com/locations.aspx?k=("Hospital")
Find locations by <input name="Keyword" type="text" size="70"/><input name="Search" type="submit" value="Search"/><br/><br/>
Hospitals<input name="Hospitals" type="checkbox" value="Hospital"/>  
Offices<input name="Office" type="checkbox" value="Office"/>  
Emergency Centers<input name="EmergencyCenters" type="checkbox" value="Emergency"/> 
Out-Patient Centers<input name="Out-Patient" type="checkbox" value="Out-Patient"/> 
Facilities<input name="Facility" type="checkbox" value="Facility"/>
Upvotes: 2
Views: 7756
Reputation: 41143
You could create (inside the page http://mysite.com/locations.aspx ) a function like:
function getDefault() {
var trail = '?k=("Hospital")';
var url = "http://mysite.com/locations.aspx" + trail;
window.location = url;
}
and add onload
to the <body>
tag like
<body onload="getDefault();">
of course, it will reload the page (without user intervention) but with the new trailing parameter.
... as for the check box, you can add the proper attribute
$(document).ready(function() {
$("input[name=Hospitals]").attr('checked','checked');
}); // ready
and it will be checked on the fly.
Upvotes: 3
Reputation: 95020
In newer browsers you can use the HTML5 history api to change the url without a page reload, however, older browsers that don't support it will require a page reload.
Upvotes: 0