[thelist] RE: Javascript - New Window + Search Function - Still not there

Administrative HQ english_offline at yahoo.com
Sat Oct 8 11:33:54 CDT 2005


Hi.

Thanks very much for the reply. Unfortunately I can't
seem to get this to work right (told you I was a dummy
at this). I keep getting "syntax error" or "object
expected", which probably means something small is
missing or out of place.

Can you show me how and where to include your
suggestion in this code:

------------------------------------------------------

<script language="JavaScript" type="text/javascript">

//<![CDATA[

<!--

function startSearch(){searchString =
document.searchForm.searchText.value;if(searchString
!= ""){searchEngine =
document.searchForm.whichEngine.selectedIndex +
1;finalSearchString = "";

if(searchEngine == 1){finalSearchString =
"http://www.altavista.com/cgi-bin/query?pg=q&what=web&q="
+ searchString;}


//Several other "if's" here...


if(searchEngine == 18){finalSearchString =
"http://de.search.yahoo.com/search/de?p=" +
searchString;}location.href = finalSearchString;}}//
-->



//]]>

</script>

<form name="searchForm">

<table width="200" border cellpadding=3 cellspacing=2
bgcolor="#ebebeb">

<tr>
<td width="75" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">Search<br> for:<br>
<td width="100" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">Search<br> from:
<td width="25" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">&nbsp;
<!--<td width="100" bgcolor=lightblue><font size=1
face="Verdana, Arial, sans-serif">&nbsp;-->


<tr>
<td bgcolor=navajowhite><input style="background:
dddddd" size="2" name="searchText"
type="text"><!--<br><p>-->
<td bgcolor=navajowhite>
<select width="2" name="whichEngine"
&nbsp;
//!<onchange="startSearch()">


<option >Altavista</option>


<option>Galaxy</option>

<option selected>Google</option>

<option>Lycos</option>

<option>Yahoo!</option>
&nbsp;<br>


<td bgcolor=navajowhite valign="bottom">&nbsp;<br>
<input type="button" value="Go"
onClick="startSearch()">

</select></form>
</table>
------------------------------------------------------

Thanks very much.
David


--- Joshua Olson <joshua at waetech.com> wrote:

> > -----Original Message-----
> > From: Administrative HQ
> > Sent: Thursday, October 06, 2005 12:55 PM
> > 
> > BUT I need the search to open in a new window.
> > 
> > Trying various coding to open a window, I've
> succeeded
> > to get a blank window to come up, but it's blank!
> I
> > can't get the search results to appear in the new
> > window. I've found no help on the web for getting
> > onclick to do two things at once. The usual way of
> > giving the new window a URL doesn't seem right
> because
> > the "submit" button calls a function.
> 
> David,
> 
> Here's what you need to look at:
> 
> 1.  Add the target attribute to the form.
> 2.  Move the function to the form's onsubmit
> handler:
> 
> <form target="_blank" 
>   method="post" 
>   action="" 
>   onsubmit="return startSearch(this);">
> 
> function startSearch(form)
> {
>   // Your code goes here
>   //..
>   // Of course, since you are passing in a reference
>   // to form you should be able to simplify your
>   // code somewhat.
> 
>   form.action = finalSearchString;
>   return true;
> }
> 
> If you want the popup window to be "custom", then
> change things to the
> following:
> 
> function startSearch(form)
> {
>   // Your code goes here
>   //..
> 
>   var win = window.open(finalSearchString, '_blank',
> 'width=....');
>   return false;
> }
> 
> This code is untested, but should get you going in
> the right direction.
> 
> <><><><><><><><><><>
> Joshua L. Olson
> WAE Tech Inc.
> http://www.waetech.com/
> Phone: 706.210.0168 
> Fax: 413.812.4864
> 
> Monitor bandwidth usage on IIS6 in real-time:
> http://www.waetech.com/services/iisbm/
> 
> 
> -- 
> 
> * * Please support the community that supports you. 
> * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip
> Harvester 
> and archives of thelist go to:
> http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 



		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/


More information about the thelist mailing list