Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
139
rated 0 times [  146] [ 7]  / answers: 1 / hits: 113775  / 12 Years ago, tue, october 9, 2012, 12:00:00

I have this text field and button here



<input name=txtSearch type=text id=txtSearch class=field />            
<input type=submit name=btnSearch value= id=btnSearch class=btn onclick=javascript:SubmitFrm() />


and when the user clicks on the submit button this function is suppose to run



<script type=text/javascript>
function SubmitFrm(){
var Searchtxt = document.getElementById(txtSearch).value();
window.location = http://www.example.com/search/?Query= + Searchtxt;
}
</script>


But nothing happens, what I expecting to happen is when the user clicks on the submit button, take the value from the search text box and redirect the user to the url + the value of the search text box...



What am I doing wrong?


More From » onclick

 Answers
23

Doing this fixed my issue



<script type=text/javascript>
function SubmitFrm(){
var Searchtxt = document.getElementById(txtSearch).value;
window.location = http://www.mysite.com/search/?Query= + Searchtxt;
}
</script>


I changed .value(); to .value; taking out the ()



I did not change anything in my text field or submit button



<input name=txtSearch type=text id=txtSearch class=field />            
<input type=submit name=btnSearch value= id=btnSearch class=btn onclick=javascript:SubmitFrm() />


Works like a charm.


[#82662] Monday, October 8, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gleng

Total Points: 471
Total Questions: 107
Total Answers: 102

Location: Virgin Islands (U.S.)
Member since Fri, May 7, 2021
3 Years ago
;