Well yes but, we need to modify the script again. Before I get into that, I'd like to mention that this script can go in the head of the document or be converted to an external script and be linked to the head. The textbox/button combos can go anywhere in the body of the page and you can have as many as you need but no duplicates. That is because only one unique id is allowed and the id is, in this case, also the prefix to the page. So, let's rewrite the whole thing a bit more to allow for duplicate acting textbox/button combo's on the same page, as well as allow for optionally opening a new window:
Code:
<html>
<head>
<script type="text/javascript">
function go(numPages, textId, pagePrefix, targType) {
var page = parseInt(document.getElementById(textId).value);
if((page !== page) || (page < 1) || (page > numPages)) {
window.alert("Page does not exist.");
document.getElementById(textId).value = "";
document.getElementById(textId).focus();
}
else if (targType&&targType=='new')
window.open(pagePrefix + page + ".htm");
else window.location = pagePrefix + page + ".htm";
}
</script>
</head>
<body>
<input type="text" size="3" id="text1"/><button onclick="go(103, 'text1', 'page');">Get Page</button><br>
<input type="text" size="3" id="text2"/><button onclick="go(52, 'text2', 'footnote', 'new');">Get Footnote</button><br>
<input type="text" size="3" id="text3"/><button onclick="go(103, 'text3', 'page');">Get Page</button>
</body>
</html>
Bookmarks