Can't get value from textfield?
Posted: Fri Jul 30, 2010 9:05 am
Well I've used this code a million times before and for some reason it's not working. Below is the form. I have tried the JS in both the head and in the body of the page.
The JS function is being called. I just put an alert into the function with all other lines of code commented out and an alert appeared. As soon as I include the line that gets the value from the textfield nothing happens.
Any ideas?
Code: Select all
<script type="text/javascript">
function searchFunc() {
var searchString = document.getElementByName("searchString").value;
alert(searchString);
window.location = "http://www.mysite.com/webdesignblog/search/" + searchString + "/";
}
</script>
Code: Select all
<form action="javascript:searchFunc()" name="searchform" id="searchform" method="get">
<input type="text" id-"searchString" name="searchString" /><input type="submit" name="action" value="Search" onClick="this.submit"/>
</form>
Any ideas?