| | |
change message on form
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 28
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Jun 2008
Posts: 28
Reputation:
Solved Threads: 0
I've used following code and it works fine with IE but not with fire fox.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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>" }
Last edited by ~s.o.s~; Jul 6th, 2008 at 10:35 am. Reason: Added code tags, learn to use them.
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
•
•
Join Date: Feb 2007
Posts: 72
Reputation:
Solved Threads: 0
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!
•
•
Join Date: Feb 2007
Posts: 72
Reputation:
Solved Threads: 0
Ok, instead of using name in forms, you need to use id for firefox
My Website <-- check out my site!
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
•
•
Join Date: Feb 2007
Posts: 72
Reputation:
Solved Threads: 0
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!
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
•
•
Join Date: Feb 2007
Posts: 72
Reputation:
Solved Threads: 0
•
•
•
•
Just because it works doesn't mean it is correct and will surely always work. IE has a peculiar habit of working withNAMEwhen it doesn't find an element with a given ID. Sodocument.getELementById('someId')will first look for an element with anIDof 'someId' and failing to find so will look for an element havingNAME'someId'. That's why it *works* in IE in your case. It it worked withNAME, don't you wonder why they kept the name of the function asgetElementById?
My Website <-- check out my site!
![]() |
Similar Threads
- How to Detect Change on ASP.NET Form and Prompt Client to Save (ASP.NET)
- Change output in cgi script (Perl)
- Send form inputs to email address (PHP)
- Learning PHP but problem with script (PHP)
- 'Lock Down' a form (PHP)
- E-mail form data quick and easily with PHP (PHP)
- Form not sending email (PHP)
- Using SelectedIndexChanged to change another column on the datagrid (C#)
- Want script to make an email form (HTML and CSS)
- Error Creating Folder message during installation (OS X)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Adding a table row full of elements to the end of a table programatically
- Next Thread: Javascript to stop Background Audio in html
Views: 1655 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets api blackjack browser bug captchaformproblem checkbox child class close cookies createrange() cursor date debugger dependent developer disablefirebug dom dropdown editor element embed engine events explorer ext file flash form forms game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images internet java javascript javascripthelp2020 jquery jsf jsfile jump libcurl maps margin math matrixcaptcha media mp3 mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming progressbar rated runtime safari scriptlets scroll search security session shopping size software solutions star stars stretch synchronous tweet unicode web webkit webservice window wysiwyg \n






