Apr 30th, 2008, 02:04
|
#1 (permalink)
|
|
Junior Member
Join Date: Mar 2008
Location: seattle.wa
Posts: 15
|
code help please
can't get this code to work, what it's supposed to do is run the first function and and it's parameters through the second function. The first function works fine, what it does is validates the text input to make sure it doesn't have something it's not supposed to have, then searches google with the word or phrase in the text input. The second function will allow the user to press enter while in the text input to search instead of clicking on the search button, but it is supposed to access the first function, but doesn't, I've done this with other functions before, for some reason, this search function doesn't work. please help me out. Thanks for any help.
- Code: Select all
<html>
<head>
<title></title>
<script language="JavaScript">
function enable_it(search_id, search_text_id, search_text_stop){
if(document.getElementById(search_text_id).value != 'please enter search word(s)' && document.getElementById(search_text_id).value != ''){
document.getElementById(search_id).disabled =true
document.getElementById(search_text_stop).disabled =true
document.getElementById(search_id).value = 'searching...'
window.location = 'http://www.google.com/search?hl=en&q=' + document.getElementById(search_text_id).value
}
else{
document.getElementById(search_text_id).value = 'please enter search word(s)'
document.getElementById(search_text_id).style.color = 'red'
}
}
function press_it(e, search_id, search_text_id, search_text_stop){
var ieff = ''
if(window.event){
var ieff = e.keyCode
}
elseif(e.which){
var ieff = e.which
}
if(ieff =="13"){
enable_it(search_id, search_text_id, search_text_stop);
}
}
</script>
</head>
<body>
<form>
<input type="text" id="search_text" value="please enter search word(s)" size="40" onFocus="this.value = ''; this.style.color='black'" onKeyPress="press_it(event, 'search', 'search_text', 'search_text')">
<input type="button" value="search" id="search" onClick="enable_it('search', 'search_text', 'search_text')">
</form>
</body>
</html>
|
|
|