shadowcaster Posted June 5, 2006 Share Posted June 5, 2006 Hello. I have a simple form and want it to open in a new window to the location with the uri "http://www.google.com/search?hl=en&q=" + searchI've get javascript errors with the current code. And when I click submit it opens the same file but appends the 'search' uri to be like this example.html?search=Search&clicked=Search...[code]<html><head> <link type="text/css" rel="stylesheet" href="rounded.css" media="screen" /> <!--[if IE]> <style type="text/css"> body {margin:0px 0px 0px 0px; padding:0px;} .container {width:250px; background;transparent;} .textbox {padding-left:15px; padding-top:0px;} .submit {padding-left:25px; padding-top:4px;}div.rounded h4 {display: block; align:center; color:black;} div.rounded h4:first-letter {padding: .3em 0 0 24px;background: transparent url(tlc_24_ddffff_60b0bf.gif) no-repeat top left} div.rounded p {background-image:url('bga.gif');}</style> <![endif]--> <script language="javascript" type="text/javascript"> do(){ var search = document.form1.search.value(); window.open("http://www.google.com/search?hl=en&q=" + search); } </script></head><body><table border="0" width="255"><tr><td><div class="container"> <div class="rounded"> <h4>Google.com</h4> <p> <form method="get" name="form1" onsubmit="do();"> <input type="text" width="50" style="background:white; border:1px solid black; padding:3px;" name="search" value="Search..." onclick="document.form1.search.value('')" /><br /> <input style="background:black; color:white; margin-left:35px; padding-top:3px; margin-top:4px; margin-bottom:4px; font-weight:bold;" type="submit" value="Search..." name="clicked" /><br /> </p> </div></div></td></tr></table></body></html>[/code]Please help. I want it to work in firefox as well as IE. Thanks. Quote Link to comment Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 too complicated for just opening a search page.Just use the "target=_blank" in the form and you don't need any javascript[code]<form method="get" action="http://www.google.com/search" target="_blank" name="form1"><input type="hidden" name="hl" value="en" />[/code]If you still want to use javascriptyou'll need to use (document.getElementById('put your field box id here').value) instead of the (document.form1.search.value) and value shouldn't have () after it. Quote Link to comment Share on other sites More sharing options...
shadowcaster Posted June 7, 2006 Author Share Posted June 7, 2006 Thanks mate. Lol. That was simple. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.