I have a form on which there is a textbox for entering mobile number. Below this I have a check box saying 'Verify number' on selecting which user gets sms for validation code. Now on the update panel I have to show the textbox for mobile in readonly form and display message next to it saying 'Verification pending' or 'Verified' depending on the status. Also I have given a link called 'Edit' on clicking which text box for mobile will become editable and the message will disappear; instead again the check box for verify number will be displayed. I need help to change the display of message and check box.

I've used following code and it works fine with IE but not with fire fox.

function editmobile()
{	
	document.getElementById("mobile").readOnly=false;
	document.getElementById("mcncode").readOnly=false;
	document.getElementById('mobile').style.background ="#FFFFFF";
	document.getElementById('mcncode').style.background ="#FFFFFF";
	document.getElementById('divsms').innerHTML="<font color=blue><input type='checkbox' name='smsalert' value='1' >Verify mobile number.</font>"
	document.getElementById('divmobileedit').innerHTML="<a href='javascript:canceleditmobile()' >Cancel</a>"
}
function canceleditmobile()
{	
	document.getElementById("mobile").readOnly=true;
	document.getElementById("mcncode").readOnly=true;
	document.getElementById("mobile").value=document.myfrm.originalmobile.value;
	document.getElementById("mcncode").value=document.myfrm.originalmcncode.value;
	document.getElementById('mobile').style.background ="#F4F4F4";
	document.getElementById('mcncode').style.background ="#F4F4F4";
	document.getElementById('divsms').innerHTML=document.myfrm.strmconf.value;
	document.getElementById('divmobileedit').innerHTML="<a href='javascript:editmobile()' >Edit</a>"
}

Firefox comes with a pre-packaged feature called Error Console (Tools -> Error Console) which highlights all the Javascript errors on your web page. You can also grab hold of Firebug, an advanced Javascript debugging utility which is a Firefox plugin.

Interesting I tried doing something similar, and in the web developer plugin debug console in firefox I got a message saying that the element is null. Mine was working in ie too, but not in firefox.

Ok, instead of using name in forms, you need to use id for firefox

You *always* need to use ID 's instead of NAME 'S when using document.getElementById .

well I did solve it using names I can post code if you want...my point is use both. Were you able to solve it dips?

Just because it works doesn't mean it is correct and will surely always work. IE has a peculiar habit of working with NAME when it doesn't find an element with a given ID. So document.getELementById('someId') will first look for an element with an ID of ' someId ' and failing to find so will look for an element having NAME ' someId '. That's why it *works* in IE in your case. It it worked with NAME , don't you wonder why they kept the name of the function as getElementById ?

Just because it works doesn't mean it is correct and will surely always work. IE has a peculiar habit of working with NAME when it doesn't find an element with a given ID. So document.getELementById('someId') will first look for an element with an ID of ' someId ' and failing to find so will look for an element having NAME ' someId '. That's why it *works* in IE in your case. It it worked with NAME , don't you wonder why they kept the name of the function as getElementById ?

I think you are a little confused....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.