Page 1 of 1

DIV not dispalyed in FireFox/Netscape

Posted: Mon Nov 15, 2004 6:58 am
by just_ht
This works fine in IE6.0 but not in FireFox/Netscape ,Please help me to sort this out .Your help is most welcomed.


Code: Select all

<script language="JavaScript1.2">
<!--Client Side Validation-->
  
   
   // displays additional spouse details inputs if marital status is selected as 'married'.
     function showSpouseForm() &#123; 
        if (document.form.maris.options&#1111;document.form.maris.selectedIndex].value ==2)
		
          &#123;
		  document.getElementById('spouseform').style.display = 'inline';
		    return true;
		
		  &#125;
		
		else
		  &#123;
            document.getElementById('spouseform').style.display = 'none';
			document.form.sname.value = "";
			document.form.sfullname.value = "";
			document.form.sedu.value = "";
			document.form.sbldgp.value = "";
			document.form.sprofession.value = "";
			document.form.sbday.value = "";
			document.form.sbmonth.value = "";
			document.form.sbyear.value = "";
		    return false;
		  &#125;	
		 &#125;
</script>

<select name="maris" onchange="showSpouseForm()">
        <option value=""> 
        <center>
          - 
        </center>
        </option>
        <option   value="1"><span>Single</span></option>
        <option value="2"   ><span>Married</span></option>
      </select>


<div id="spouseform" style="display:none;">
	    <table width="100%" >
          <tr> 
            <td colspan="4" height="21" valign="top" bgcolor="#cacaca"> 
              
              <center>
                <b><span class="blanc"><font color="#306090" size="+1">Enter Your Spouse's Detail</font></span></b> 
              </center>
             
            </td>
          </tr>
          <tr> 
            <td width="222" height="32"><span><b>Name <font color="red">*</font> 
              : </b></span></td>
            <td width="241" valign="top"> 
              <input type="text" value="" name="sname">
            </td>
            <td valign="top" width="240"><span><b>Fullname <font color="red">*</font> 
              : </b></span></td>
            <td width="248" valign="top"> 
              <input type="text" value="" name="sfullname">
            </td>
          </tr>
          <tr> 
            <td width="222" height="32"><span><b>Education <font color="red">*</font> 
              : </b></span></td>
            <td> 
              <input type="text" value="" name="sedu">
            </td>
            <td valign="top"><span><b>Blood gp.<font color="red">*</font> : </b></span></td>
            <td valign="top"> 
              <input type="text" value="" name="sbldgp">
            </td>
          </tr>
          <tr> 
            <td height="25"><span><b>Profession : </b></span></td>
            <td colspan="3" valign="top"><span> 
              <select name="sprofession">
                <option value=""> 
                <center>
                  - 
                </center>
                </option>
                <option  value="m">top executive</option>
                <option  value="p">self-employed</option>
                <option  value="ac">teacher/researcher</option>
                <option  value="t">computer programer/engineer</option>
                <option  value="ot">other technical profession/engineering</option>
                <option  value="cs">customers service/customers support </option>
                <option  value="ad">administrative department</option>
                <option  value="sa">Marketing</option>
                <option  value="tc">Craftsman</option>
                <option  value="st">Student</option>
                <option  value="ks">high school student/college student</option>
                <option  value="h">at home services</option>
                <option  value="se">independent</option>
                <option  value="n">unemployed</option>
                <option  value="r">Retired</option>
                <option  value="o">other</option>
              </select>
            </td>
          </tr>
          
          <tr> 
            <td height="60"><span><b>Date of birth<font color="red">*</font></b> 
              : </span></td>
            <td> 
              <input type="text" name="sbday" value="" size="2"><span>
              <select name="sbmonth">
                <option value=""> 
                <center>
                  - 
                </center>
                </option>
                <option value="1" >January</option>
                <option  value="2">February</option>
                <option  value="3">March</option>
                <option value="4" >April</option>
                <option  value="5">May</option>
                <option  value="6">June</option>
                <option  value="7">July</option>
                <option value="8"  >August</option>
                <option  value="9">September</option>
                <option  value="10">October</option>
                <option  value="11">November</option>
                <option value="12" >December</option>
              </select>
              <input type="text" name="sbyear" value="" size="4">
            </td>
            <td></td>
            <td></td>
          </tr>
        </table>
</div>

Posted: Mon Nov 15, 2004 3:15 pm
by jollyjumper
Hi Just,

Firefox and netscape are more picky on different variable types than internet explorer(you could turn it around and say that internet explorer is just too easy on it), but the variable document.form.maris.options[document.form.maris.selectedIndex].value is a string, so the value 2 in the IF statement should be quoted, like this:

Code: Select all

if (document.form.maris.options&#1111;document.form.maris.selectedIndex].value =="2")
After this little change it works for me in IE6 and Firefox.

Good luck.

Greetz Jolly.

Thanks a lot.

Posted: Mon Nov 15, 2004 10:41 pm
by just_ht
Thanks a lot Jolly,So nice of U.
After the minor changes it works on IE6,FireFox,Netscape7.1(Hope It gets going on others too).

Posted: Tue Nov 16, 2004 1:43 am
by jollyjumper
You're welcome. If you could place the script on a domain I can reach through the internet I can try it for you on IE 5.2 and Safari on the Mac.

greetz Jolly.

Posted: Tue Nov 16, 2004 8:21 am
by just_ht
Hi Jolly,

Actually that will take some time ,it's OK ...working fine on all target
Browsers .