Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy answer to this question, I hope

Status
Not open for further replies.

Carzstop

Technical User
May 20, 2000
13
0
0
ES
Hello everybody.

I have this code:

<form name=&quot;myform&quot;>
.......

<input type=&quot;text&quot; name=&quot;searchtxt&quot;>

</form>

.......

<A HREF='javascript:void(str=document.myform.searchtxt.value);if(str){location.href=&quot;
.......

So, what I have to do to achieve that the results of Altavista's search appear in a new window?. I'm really a beginner, so I will apreciate your help. Thanks.
[sig][/sig]
 
Try the code below...

Code:
<html>
<body>
<form name=frmSearch id=frmSearch>
 <input type=text name=txtSearch id=txtSearch width=40><br>
 <input type=button value=&quot;Search AltaVista&quot; onClick=&quot;fnSearch(txtSearch.value)&quot;>
</form>
</body>
<script language=&quot;javascript&quot;>
 function fnSearch(strSearch){
  if(strSearch){
   var strHTML = &quot;[URL unfurl="true"]http://www.altavista.com/cgi-bin/query?pg=q&kl=xx&q=&quot;[/URL]
   strHTML += strSearch.replace(/\s/gi,&quot;+&quot;);
   window.navigate(strHTML);
  }
 }
</script> 
</html>

Hope it helps,

[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Another possibility, using almost all your code:

<form name=&quot;myform&quot;>
<input type=&quot;text&quot; name=&quot;searchtxt&quot;>
<A HREF='javascript: go_av()'>Altavista</A>
</form>

<script language=javascript>
function go_av()
{
void(str=document.myform.searchtxt.value);
if(str)
{
url= &quot; + escape(str).split(&quot;%20&quot;).join(&quot;+&quot;);
window.open(url,&quot;Altavista&quot;);
}
}
</script>


I tested it and it worked,

Rascal [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top