View Full Version : Disabling and clearing fields
sorry this is probably simple but i search every where on CF and cant find it :confused: . I have a text field and a list field; when i click on a radio button i want the text and list fields to be disabled while at the same time the contents of the text field to be cleared and a value in the list to be selected.
Thanks for any help!! ;)
07-07-2005, 04:46 PM
Remember, disabling a form field will NOT send the form field value to the server!!
<input type="radio" onClick="doSomething()">
document.formname.selectName.selectedIndex=0; // pick the number of the option
document.formname.selectName.options[document.formname.selectName.selectedIndex].selected = true; // needed to be cross-browser
thanks mate just what i needed!!! :thumbsup:
one last thing is it possible add text to the list field without it having to be in the list??
btw how do u know all this, are there ne tutorials u go 2?
07-07-2005, 07:41 PM
A select element has options. The options have text. So, no, you can't put text in a select element without it being an option.
You can, however, dynamically create any element you like and you can give options no value (so they don't really do much).
Tell me more about why you want text in there and let's see what kid of solution works best for you.
As to where I learned it, all over the place! :)
I have a bunch of references and tutorials links here.
im creating a mailing list page. users have a choice of subscribing and unsubscribing.
there are 3 fields- name, email and what they want to subscribe to. i have been able to make it so if they select the subscribe radio button all the text fields are blank and the list field goes to 'Please select'.
when they click unsubscribe the name and list fields disable of which they are only allowed to enter their email.
i just wanted to show from the disabled fields that they must enter their email address. i have been able to do this for the text field by having 'enter email address' in the disabled field. i could put the 'enter email address' in the list but when they are subscribing they can see this option which does not look good. thats why i wanted a way to just add text when unsubscribing but remove it when subscribing!!
sorry for the long message!! hope u get what im saying??!!
thanks vorl :o
07-08-2005, 07:20 AM
Why not just focus to the email field when the textbox and combobox are disabled?
07-08-2005, 03:01 PM
You could just hide the elements they don't need to fill out.
A very simple example:
<input type="text" name="txt"><br>
<input type="button" name="btn" onClick="document.f1.txt.style.display='none'" value="hide">
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.