i’m writing some inline javascript. it’s not working and i’m not sure why.
at the top of the index page
<meta http-equiv="Content-Script-Type" content="text/javascript" />
later on i have:
<select name='id'>
<option value=-1>New Entry</option>
<option value='1' onclick="location.replace('index.php?page=update&id=1')">2010-06-12 16:38:08</option>
<option value='2' onclick="location.replace('index.php?page=update&id=2')">2010-06-12 18:20:49</option>
<option value='3' onclick="location.replace('index.php?page=update&id=3')">2010-06-13 11:39:09</option>
</select>
what i want is for the page to be replaced when one of the option items is selected but the code is not causing a page refresh and i’m not sure why. is something wrong with the javascript?
Use the
onchangeevent of theselectelement:Note: The
location.replacemethod is used when you want to navigate to the page and also replace the current page in the browsing history. If you just want to navigate to the page normally, you assign the URL to thewindow.location.hrefproperty instead.