rahulr
01-19-2009, 07:17 AM
Hi All,
Following is a HTML code with javascript. Plz open it in a browser. I have posted it b4 for a seeking a help and my doubt was clarified well. Now I need one more help. If I select "Bachelors" from the environment field, then only i need the Degree Text Box Visible. Now with the script even though itz disabled, it is visible to others. But i need a script in which that box is visible only when i select "Bachelors", in all other cases invisible. Is that possible? It would be a gr8 help if some one can help me in this... :-)
<HTML><HEAD><TITLE>Electronic Deposting Form</TITLE>
<script language="JavaScript">
<!-- script start
function validateComplete(formObj) {
if (emptyField(formObj.username))
alert("Please enter the Username.");
else if (emptyField(formObj.passwd))
alert("Please enter the Password.");
else return true;
return false;
}
// Check to see if field is empty
function emptyField(textObj)
{
if (textObj.value.length == 0) return true;
for (var i=0; i<textObj.value.length; ++i) {
var ch = textObj.value.charAt(i);
if (ch != ' ' && ch != '\t') return false;
}
return true;
}
// script end -->
</script>
</head>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.3429" name=GENERATOR></HEAD>
<BODY>
<TABLE>
<TBODY>
<TD><FONT face=Times size=5> <B>Electronic Depositing
Form</B></FONT></TD></TR></TBODY></TABLE>
<FORM name="Iform" action="saveFRM.cgi" method="post" onSubmit="return validateComplete(document.Iform)">
<TABLE cellSpacing=10 cellPadding=5>
<TBODY>
<TR>
<TD style="FONT-FAMILY: arial"><B>Username</B></TD>
<TD>:</TD>
<TD><INPUT maxLength=255 size=21 name=username>
<TD></TD>
<TR>
<TD style="FONT-FAMILY: arial"><B>Password</B></TD>
<TD>:</TD>
<TD><INPUT type=password maxLength=255 size=21 name=passwd>
<TD></TD>
<TR>
<TD style="FONT-FAMILY: arial"><B>ELIGIBILITY</B></TD>
<TD>:</TD>
<TD><SELECT size=1 name='environ' id=environment onchange='enable()'>
<OPTION value=bachelors selected>BACHELORS</OPTION>
<OPTION value=diploma>Diploma</OPTION>
<OPTION value=isd>ISD</OPTION>
<OPTION value=dataprotector>DPTP</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD style="FONT-FAMILY: arial"><B>Degree</B></TD>
<TD>:</TD>
<TD><SELECT size=1 name='degree' id='degree'>
<OPTION value=art>Art</OPTION>
<OPTION value=science>Science</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD>
<TD></TD>
<TR>
<TD><INPUT type=submit value=Submit v:shapes="_x0000_s1034"></TD>
<TD> </TD>
<TD><INPUT type=reset value=Clear v:shapes="_x0000_s1035\"></TD></TR></TBODY></TABLE></FORM></BODY></HTML>
<script>
function enable()
{
if (!(document.getElementById('environment').value=="bachelors"))
{
document.getElementById('degree').value="";
document.getElementById('degree').disabled=true;
}
else
{
document.getElementById('degree').disabled=false;
}
}
</script>
Following is a HTML code with javascript. Plz open it in a browser. I have posted it b4 for a seeking a help and my doubt was clarified well. Now I need one more help. If I select "Bachelors" from the environment field, then only i need the Degree Text Box Visible. Now with the script even though itz disabled, it is visible to others. But i need a script in which that box is visible only when i select "Bachelors", in all other cases invisible. Is that possible? It would be a gr8 help if some one can help me in this... :-)
<HTML><HEAD><TITLE>Electronic Deposting Form</TITLE>
<script language="JavaScript">
<!-- script start
function validateComplete(formObj) {
if (emptyField(formObj.username))
alert("Please enter the Username.");
else if (emptyField(formObj.passwd))
alert("Please enter the Password.");
else return true;
return false;
}
// Check to see if field is empty
function emptyField(textObj)
{
if (textObj.value.length == 0) return true;
for (var i=0; i<textObj.value.length; ++i) {
var ch = textObj.value.charAt(i);
if (ch != ' ' && ch != '\t') return false;
}
return true;
}
// script end -->
</script>
</head>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.3429" name=GENERATOR></HEAD>
<BODY>
<TABLE>
<TBODY>
<TD><FONT face=Times size=5> <B>Electronic Depositing
Form</B></FONT></TD></TR></TBODY></TABLE>
<FORM name="Iform" action="saveFRM.cgi" method="post" onSubmit="return validateComplete(document.Iform)">
<TABLE cellSpacing=10 cellPadding=5>
<TBODY>
<TR>
<TD style="FONT-FAMILY: arial"><B>Username</B></TD>
<TD>:</TD>
<TD><INPUT maxLength=255 size=21 name=username>
<TD></TD>
<TR>
<TD style="FONT-FAMILY: arial"><B>Password</B></TD>
<TD>:</TD>
<TD><INPUT type=password maxLength=255 size=21 name=passwd>
<TD></TD>
<TR>
<TD style="FONT-FAMILY: arial"><B>ELIGIBILITY</B></TD>
<TD>:</TD>
<TD><SELECT size=1 name='environ' id=environment onchange='enable()'>
<OPTION value=bachelors selected>BACHELORS</OPTION>
<OPTION value=diploma>Diploma</OPTION>
<OPTION value=isd>ISD</OPTION>
<OPTION value=dataprotector>DPTP</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD style="FONT-FAMILY: arial"><B>Degree</B></TD>
<TD>:</TD>
<TD><SELECT size=1 name='degree' id='degree'>
<OPTION value=art>Art</OPTION>
<OPTION value=science>Science</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD>
<TD></TD>
<TR>
<TD><INPUT type=submit value=Submit v:shapes="_x0000_s1034"></TD>
<TD> </TD>
<TD><INPUT type=reset value=Clear v:shapes="_x0000_s1035\"></TD></TR></TBODY></TABLE></FORM></BODY></HTML>
<script>
function enable()
{
if (!(document.getElementById('environment').value=="bachelors"))
{
document.getElementById('degree').value="";
document.getElementById('degree').disabled=true;
}
else
{
document.getElementById('degree').disabled=false;
}
}
</script>