[Javascript] Multiple If Statements don't work in Netscape

Peter Brunone peter at brunone.com
Tue May 1 10:03:42 CDT 2001


Thomas,

    I've tried something fairly similar, and as I recall, it worked in
Netscape.  There shouldn't be any difference in basic logic structures like
this.

    Perhaps, in lieu of a form submit with a GET, you could dynamically
build a URL and send it that way.  NS may have a hangup with multiple form
submissions, but I know it can handle opening multiple windows with multiple
links...

Cheers,

Peter

----- Original Message -----
From: <thomas.churm at pixelpark.com>
To: <javascript at LaTech.edu>
Sent: Tuesday, May 01, 2001 9:43 AM
Subject: [Javascript] Multiple If Statements don't work in Netscape


> hi,
>
> i've been playing around trying to make a meta-search form by copying
> search-forms from various search engines.  the form worked great, but
> then i added checkboxes.  if a checkbox is checked, then the words
> entered into the search-form should be automatically searched by all
> of the search-engines checked.  the code below works great in MSIE
> but not in Netscape--in netscape it only searches in the last search
> engine checked, and i think it's due to the syntax of my JavaScript--
> i have a whole lot of If statements here and NS doesn't process them
> correctly--it's like it reads them as "if else" statements instead of
> as a bunch of separate if statements.
>
> i know that i could write:
> if ((document.sameValue.goo.checked == true)&&
> (document.sameValue.lyc.checked == true)){
> document.forms[1].submit();
>         document.forms[2].submit();
> }
>
> but i would have to write long, complicated if statements for all
> permutations:  1 searchbox checked, 2 searchboxes checked, another 2
> searchboxes checked, etc...
>
> there's gotta be an easier way, i just don't have a clue what it is.
>
> any hints would be great!
>
> thanks,
>
> tom
>
> >>>>>>>CODE FOLLOWS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> <html>
> <head>
> <title></title>
> <script language="JavaScript">
> <!--
>
> function sendAll() {
> /*Define defaultValue*/
> var defaultValue = document.sameValue.allInputs.value;
>
> /*Give all forms same defaultValue*/
> document.forms[1].q.value = defaultValue;
> document.forms[2].query.value = defaultValue;
> document.forms[3].p.value = defaultValue;
> document.forms[4].q.value = defaultValue;
> document.forms[5].elements[1].value = defaultValue;
>
> /*Send off all forms if the right checkbox is checked*/
> if (document.sameValue.goo.checked == true){
> document.forms[1].submit();
> }
> if (document.sameValue.lyc.checked == true){
> document.forms[2].submit();
> }
> if (document.sameValue.yah.checked == true){
> document.forms[3].submit();
> }
> if (document.sameValue.fir.checked == true){
> document.forms[4].submit();
> }
> if (document.sameValue.con.checked == true){
> document.forms[5].submit();
> }
>
> }
> //-->
> </script>
> </head>
>
> <body text="#000000" bgcolor="#dfdfdf" topmargin="0" leftmargin="0"
> rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
>
> <h2>MetaSearch Test</h2><br>
>
> <form name="sameValue" id="sameValue" onSubmit="sendAll()">
> <table cellspacing="0" cellpadding="0" border="0">
> <tr>
>     <td>google.de</td>
>     <td><input type="checkbox" name="goo" value="" checked></td>
> </tr>
> <tr>
>     <td>lycos.de</td>
>     <td><input type="checkbox" name="lyc" value="" checked></td>
> </tr>
> <tr>
>     <td>yahoo.de</td>
>     <td><input type="checkbox" name="yah" value="" checked></td>
> </tr>
> <tr>
>     <td>fireball.de</td>
>     <td><input type="checkbox" name="fir" value="" checked></td>
> </tr>
> <tr>
>     <td>conrad.com</td>
>     <td><input type="checkbox" name="con" value="" checked></td>
> </tr>
> </table>
>
> <input type="text" name="allInputs" size=25 maxlength=50>
> <br>
> <a href="javascript:sendAll()">Submit</a>
> </form>
>
>
>
> <!--  Google-->
> <form action=http://www.google.de/search method=get name=f
> target="_blank">
> <input type=hidden value="" name=q size=50 maxlength=256><br><input
> name=hl type=hidden value=de>
> <input type=hidden name=meta value="lr=lang_de">
> </form>
>
> <!--  Lycos-->
> <FORM ACTION="http://www.lycos.de/cgi-bin/pursuit" METHOD="GET"
> NAME="mainform" target="_blank">
> <input type="hidden" name="matchmode" value="and">
> <input type="hidden" name="mtemp" value="main">
> <input type="hidden" name="etemp" value="error">
> <INPUT TYPE="hidden" NAME="query" SIZE="30">
> <INPUT TYPE="hidden" NAME="cat" VALUE="de_spkr" CHECKED>
> </form>
>
> <!--  Yahoo-->
> <form action="http://de.search.yahoo.com/search/de" target="_blank">
> <input type=hidden name=p size=30>
> </form>
>
> <!-- Fireball -->
> <form method="GET" action="http://suche.fireball.de/fcgi/query.fcg"
> target="_blank">
> <input type="hidden" name="action" value="query"><input type="hidden"
> name="pg" value="express">
> <input type="hidden" name="q" size="25">
> <input type="hidden" name="what" value="german_web">
> </form>
>
>
> <!--  conrad.com-->
> <form action="http://www.conrad.de/cgi-bin/conshop/index.cgi"
> method="get" target="_blank"><input type="hidden" name="PP_EV
> [SEARCHINIT]" value="1">
> <input type="hidden" name="PP_PAR[SEARCHTEXT]" size=15 maxlength=50>
> </form>
> </body>
> </html>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list