Jump to content

Archived

This topic is now archived and is closed to further replies.

shadowcaster

JS Newbie needs help

Recommended Posts

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=" + search

I'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.

Share this post


Link to post
Share on other sites
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 javascript

you'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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.