Hi I posted this a while back but can't find the thread and don't think anyone answered anyway. Basically I want a field to be greyed out until someone checks the premium listing radio button. I assume JS is the only way to do this. Please can anyone advise if it would be possible and how it would be done. Im a JS no hoper. I tried to learn it failed. He he
First use html to disabled the field, using disabled option. Then use JS onclick attribute to enable it, like: onclick="document.getElementById('disabledfieldname').disabled='false';" or something along those lines. Peace,
Yup. Your HTML should be like this: <form id="mainForm" action="" method="post"> ... <label>Enable Text Box <input onclick="enableBox('mainForm', 'textbox')" type="radio" name="boxEnabler" /></label> <label>Textbox <input type="text" name="textbox" /> ... </form> <script type="text/javascript"><!-- document.getElementById('mainForm').textbox.disabled='true'; //--></script> Code (markup): Then your JS (don't have to have this as a separate function, just neater and reusable): function enableBox(formId, boxName){ document.getElementById(formId).boxName.disabled='false'; } Code (markup): That should work. What it does is writes the form in HTML, then disables the text box with JS (equivelant to using onload, but faster), so people without JS can still use it. That function will enable any input, select or textarea if you need it, but obviously it works fine with just one
or you could have the box not even appear until the radio buton is checked, triggering the elementbyid in a <div> so that Ajax then makes it pop out <SHWING> like magic ..almost.