Reputation: 13859
I have a test server with a page using jquery autocomplete. The autocomplete feature works fine if I connect to the server using Firefox 3.6. Unfortunately it doesn't work in Chrome or Firefox 5. Here is the html:
<html>
<head>
<title>Test Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<link type="text/css" href="/static/css/jquery-autocomplete/jquery-ui-1.8.14.custom.css" rel="stylesheet" />
<script>
$(document).ready(function(){
url = "/autocomplete/";
$("#searchInput").autocomplete({
source: url
});
});
</script>
<link rel="stylesheet" href="/static/css/site.css" />
</head>
<body>
<div id="content">
<script language="JavaScript">
<!--
function setSearchUrl() {
searchUrl = "/search/" + document.searchForm.nickname.value + "/"
document.searchForm.action = searchUrl;
}
//-->
</script>
<h3>Search</h3>
<form
name="searchForm"
action="/search"
method="get"
onSubmit="setSearchUrl()"
autocomplete="off">
<input id="searchInput" type="text" name="nickname" autocomplete="off">
<input type="submit" value="Search">
</form>
<script language="JavaScript">
<!--
document.searchForm.nickname.focus();
//-->
</script>
</div>
</body>
</html>
Any ideas on what might be going awry?
edit: firebug (in both browser versions) did not show any errors. Development tools in Chrome did not seem to complain either.
Thanks!
-Travis
Upvotes: 0
Views: 1896
Reputation: 14435
Check out this fiddle: http://jsfiddle.net/jensbits/AmvsX/
It should get you pointed in the right direction and the setSearchUrl function should not be necessary.
Upvotes: 1
Reputation: 12680
I'll be this line is your offender:
document.searchForm.nickname.value
What do you get when you type that expression into the console?
Upvotes: 0