...

View Full Version : Javascript Text box highlight



needhelp26
07-15-2004, 02:01 AM
This javascript code works well in IE5+ but does not work on Netscape. Can someone please give me solution to work in Netscape also:



<script language="javascript">
function yes() {
MMDiv.Style.visibility='visible';
form1.fieldname.focus();
}
</script>


Form:

Textbox under <div></div> tag has hidden value. so when clicked on yes, the textbox appears.

dumpfi
07-15-2004, 02:12 AM
<script type="text/javascript">
function yes() {
document.getElementsByName('MMDiv')[0].style.visibility='visible';
document.form1.fieldname.focus();
}
</script>
If this doesn't help you, post the whole code so that we can find the error.

dumpfi

needhelp26
07-15-2004, 02:21 AM
Thankyou. I will try and if there is an error will post again with full code.

jamescover
07-15-2004, 03:13 AM
Highlight ???

needhelp26
07-16-2004, 02:59 AM
I tried that code and didn't work.



<script language="javascript">
function yes() {
MMDiv.Style.visibility='visible';
form1.name.focus();
}
</script>


Form:

<table>
<tr>
<td><input type="radio" name="fieldname" value="yes" onclick="Yes();">Yes
<div id="MMDIV" style="visibility:hidden">
<input type "text" name="name" size="30"></div>
</td>
</tr>
</table>

glenngv
07-16-2004, 03:12 AM
Javascript is case-sensitive and you have to access elements properly.

document.getElementById('MMDIV').style.visibility='visible';
document.form1.name.focus();

needhelp26
07-16-2004, 03:24 AM
I tried getElementById also, but it didn't work.

glenngv
07-16-2004, 05:16 AM
Are you calling the correct function?


function yes() {
document.getElementById('MMDIV').style.visibility='visible';
document.form1.name.focus();
}
...
<input type="radio" name="fieldname" value="yes" onclick="yes();">

You had a Yes() in the onclick in your original code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum