Jump to content


Photo

JS Newbie needs help


  • Please log in to reply
2 replies to this topic

#1 shadowcaster

shadowcaster
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationUK

Posted 05 June 2006 - 11:13 PM

Hello. I have a simple form and want it to open in a new window to the location with the uri
"http://www.google.co...earch?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...
<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>
Please help. I want it to work in firefox as well as IE. Thanks.
--Lurking out of sight, Night shall fall and feed my frenzy, Beneath an eerie moon a change comes over me--[br]Check out Symphony X (The oddysey album) if you like heavy metal

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 June 2006 - 11:47 PM

too complicated for just opening a search page.

Just use the "target=_blank" in the form and you don't need any javascript
<form method="get" action="http://www.google.com/search" target="_blank" name="form1">
<input type="hidden" name="hl" value="en" />

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.

NoGray.com


#3 shadowcaster

shadowcaster
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationUK

Posted 07 June 2006 - 12:52 AM

Thanks mate. Lol. That was simple.
--Lurking out of sight, Night shall fall and feed my frenzy, Beneath an eerie moon a change comes over me--[br]Check out Symphony X (The oddysey album) if you like heavy metal




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users