Select Categories Below
Status: Closed Points: 75 Time: 15:49 - Oct 30, 2007
kassidi6
I looked at one your older posts and im currently using your following script: <html> <head> <title>Test</title> <script type="text/javascript"> function disable_controls( state) { var frm = document.forms[0] ; var len = frm.elements.length ; var cnt = 0 ; for ( var i=0; i < len; i++) { var elem = frm.elements[i] ; if (elem.type != "hidden") { elem.disabled = state ; } } } </script> </head> <body> <button onclick="disable_controls( false)">Enable</button> <button onclick="disable_controls( true)">Disable</button> <br> <form action="yours" method="POST" enctype="application/x-www-form-urlencoded"> <input name="t1" disabled size="10" value="ini val" type="text"> <br> <textarea name="t2" cols="10" disabled >abc def</textarea> </form> </body> </html> -------------------------------------------------------- The way i'm actually using it is instead of using buttons to disable/enable the following fields, i'm using a radio type field. Yes (is the Enable value) and No (Disable value). The problem i'm having is that when i a select No, it will gray out radio field. I can't then go back and select Yes. I tried tweaking the code a bit, but with no success. Is there a way to workaround this? Thank you very much.
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
Date:: Oct 30, 2007
Time:: 16:05
oops, i forgot to mention that i changed the code of the html body to be as follow: -------------------------------------------------------------------------------------------- <body> <form action="yours" method="POST" enctype="application/x-www-form-urlencoded"> <input type="radio" value="Yes" name="Marketing_IC_Contact_Info__em" onclick="disable_controls( false)">Yes <input type="radio" value="No" name="Marketing_IC_Contact_Info__em" onclick="disable_controls( true)">No <br> <input name="t1" disabled size="10" value="ini val" type="text"> <br> <textarea name="t2" cols="10" disabled >abc def</textarea> </form> </body> ---------------------------------------------------------------------------------------------------------------- The reason it's behaving the way i mentioned earlier is because i moved the radio field inside the form, which is how we want it to be. Any help on how to get it to work by having the radio field inside the form will be much appreciated. Thank you.
rcastagna
Date:: Nov 07, 2007
Time:: 07:35
kassid, In your javascript, you're iterating through all the controls and disabling them, including your radio button. That's why it's giving you the behavior you're experiencing. Basically, you're still going to iterate all the controls in the form, but when you get to your radio button(s), you're going to leave them enabled by ignoring them... if (elem.type != "hidden") { if (elem.type != "radio") { elem.disabled = state ; } } That will keep all radio buttons enabled. You can refine it by looking at the name or adding an id property and excluding the radio button(s) programmatically. I hope this helps, Ric
Time:: 16:46
missed that. works out fine now. Thank you.
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
how do i open a file dialog in .net (a windows application)?
When trying to alter a table in MySQL, I get "Error on rename... (Errcode: 13)"
how do i delete a top domain cookie from a subdomain?
Hi Am Rakesh, Am generating User Data List, Details Given Below.Please Help Me.
What is some free software for recording the movements on your computer screen t...
Good project management software?
You have 100 characters to use
Rank
Expert
Points
1.
75
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment