Log in

View Full Version : checkbox validation



call_sreenu
07-11-2008, 09:46 AM
hi,i have single checkbox and radio button with that iam genarating multiple checkboxes radio's.if both selected then only iam performing the import the seleted checkbox(topic-contains no of questions) topic into selected radio button topic(contains no of questions),if u not select any one it will say "please select radio/check box".

Then ,i can select multiple checkboxes and only one radio button.if iselect multiple checkboxes(ex:-4 checkboxes) and radio button.all the selected(4) topics questions will be imported to selected radio button after clicking "import " button.


My question is .after selecting 4 checkboxes,if i not select radio button.iam sending a error msg "please select radio buuton" but after displaying error message that check boxes are clearing(becoming unchecked ) but that should be checked .how can i do that,

Please Help.................

Thank You,
Sreenu

Nile
07-11-2008, 06:27 PM
Can you please use correct grammar and spelling? I can't understand you a bit.
Since I couldn't understand you, I've made a one examples for you. (Of what I thought you want)
Radio Checkbox, changes inputs(this one is not in an html form, although its simple to make it into one. Its also, well I made it a phone number script, easy to change too).


<script type="text/javascript">
function changeRadio(el,cell){
if(el.checked="yes"){
document.getElementById('hidden').innerHTML=((cell)? 'Cell: ' : 'Home: ')+'<input type="text" />';
} else {
document.getElementById('hidden').innerHTML='';
}
}
</script>
<h2>Please fill in your phone data</h2>
Home Phone: <input type="radio" onClick="changeRadio(this,false);" name="phone"/><br />
Cell Phone: <input type="radio" onClick="changeRadio(this,true);" name="phone"/><br />
<span id="hidden"></span>