----------------------------------- apomb Tue Mar 08, 2011 1:50 pm Submitting a form using javascript ----------------------------------- Hey guys, Its been a while since ive been around, since I haven't been on the web-dev front until just recently, so this question will sound very noobish. There is an issue with the search function on my website, I have gotten the search to work correctly when using the enter key to submit the form, however, when the "search" button (which is simply an image) is clicked, it simply goes to google without the form actually being submitted. [code] var domainroot="www.herpderp.com"; function Gsitesearch(curobj){ curobj.q.value="site:"+domainroot+" "+curobj.qfront.value } function submitSearchForm() { var myForm = document.getElementById("searchForm"); myForm.submit(); } [/code] Could someone shed some light on how this doesnt work? I have an idea that is has to do the submitSearchForm() ----------------------------------- DemonWasp Tue Mar 08, 2011 2:16 pm RE:Submitting a form using javascript ----------------------------------- You're right -- you haven't bothered giving your form an ID so trying to get that element by ID isn't going to work very well. As a side note, consider just using the form discussed here: http://www.codetoad.com/html/buttons/image_submit_button.asp Basically, you skip onclick / javascript-links in favour of an image that just submits the form the same way pressing enter would. ----------------------------------- apomb Tue Mar 08, 2011 4:18 pm Re: Submitting a form using javascript ----------------------------------- Well, I'm specifically having trouble with the following section: [code] [/code] This code is untested, but I think it should work now. EDIT: it does. Thank You.