change message on form

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jun 2008
Posts: 28
Reputation: dips255 is an unknown quantity at this point 
Solved Threads: 0
dips255 dips255 is offline Offline
Light Poster

change message on form

 
0
  #1
Jul 3rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 28
Reputation: dips255 is an unknown quantity at this point 
Solved Threads: 0
dips255 dips255 is offline Offline
Light Poster

Re: change message on form

 
0
  #2
Jul 5th, 2008
I've used following code and it works fine with IE but not with fire fox.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function editmobile()
  2. {
  3. document.getElementById("mobile").readOnly=false;
  4. document.getElementById("mcncode").readOnly=false;
  5. document.getElementById('mobile').style.background ="#FFFFFF";
  6. document.getElementById('mcncode').style.background ="#FFFFFF";
  7. document.getElementById('divsms').innerHTML="<font color=blue><input type='checkbox' name='smsalert' value='1' >Verify mobile number.</font>"
  8. document.getElementById('divmobileedit').innerHTML="<a href='javascript:canceleditmobile()' >Cancel</a>"
  9. }
  10. function canceleditmobile()
  11. {
  12. document.getElementById("mobile").readOnly=true;
  13. document.getElementById("mcncode").readOnly=true;
  14. document.getElementById("mobile").value=document.myfrm.originalmobile.value;
  15. document.getElementById("mcncode").value=document.myfrm.originalmcncode.value;
  16. document.getElementById('mobile').style.background ="#F4F4F4";
  17. document.getElementById('mcncode').style.background ="#F4F4F4";
  18. document.getElementById('divsms').innerHTML=document.myfrm.strmconf.value;
  19. document.getElementById('divmobileedit').innerHTML="<a href='javascript:editmobile()' >Edit</a>"
  20. }
Last edited by ~s.o.s~; Jul 6th, 2008 at 10:35 am. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,653
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: change message on form

 
0
  #3
Jul 6th, 2008
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.
The romantic image of an über-programmer is someone who fires up Emacs, types like a machine gun, and delivers a flawless final product from scratch. A more accurate image would be someone who stares quietly into space for a few minutes and then says “Hmm. I think I’ve seen something like this before.” - John D
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 72
Reputation: adaykin is an unknown quantity at this point 
Solved Threads: 0
adaykin adaykin is offline Offline
Junior Poster in Training

Re: change message on form

 
0
  #4
Jul 6th, 2008
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.
My Website <-- check out my site!
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 72
Reputation: adaykin is an unknown quantity at this point 
Solved Threads: 0
adaykin adaykin is offline Offline
Junior Poster in Training

Re: change message on form

 
0
  #5
Jul 6th, 2008
Ok, instead of using name in forms, you need to use id for firefox
My Website <-- check out my site!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,653
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: change message on form

 
0
  #6
Jul 7th, 2008
You *always* need to use ID 's instead of NAME 'S when using document.getElementById .
The romantic image of an über-programmer is someone who fires up Emacs, types like a machine gun, and delivers a flawless final product from scratch. A more accurate image would be someone who stares quietly into space for a few minutes and then says “Hmm. I think I’ve seen something like this before.” - John D
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 72
Reputation: adaykin is an unknown quantity at this point 
Solved Threads: 0
adaykin adaykin is offline Offline
Junior Poster in Training

Re: change message on form

 
0
  #7
Jul 7th, 2008
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?
My Website <-- check out my site!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,653
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: change message on form

 
0
  #8
Jul 8th, 2008
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 ?
The romantic image of an über-programmer is someone who fires up Emacs, types like a machine gun, and delivers a flawless final product from scratch. A more accurate image would be someone who stares quietly into space for a few minutes and then says “Hmm. I think I’ve seen something like this before.” - John D
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 72
Reputation: adaykin is an unknown quantity at this point 
Solved Threads: 0
adaykin adaykin is offline Offline
Junior Poster in Training

Re: change message on form

 
0
  #9
Jul 8th, 2008
Originally Posted by ~s.o.s~ View Post
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....
My Website <-- check out my site!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1655 | Replies: 8
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC