Forum Moderators: open

Message Too Old, No Replies

Detect if radiobutton checked BEFORE submit

         

cameraguy

12:38 am on Dec 9, 2004 (gmt 0)

10+ Year Member



Hello folks!

Is it possible to know whether a particular readiobutton (for instance) has been checked BEFORE the submit button is clicked?

Ideally, I would like to make a textarea appear ONLY if a particular radiobutton has been checked.

Choose
O current week
O current month
O to date
O since ¦___________¦ <---- textarea should appear only if 'since' radiobutton has been checked

Thank you!

DrDoc

1:43 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To your "since" radio button, add the following:

onchange="document.getElementById('theID').style.display = (this.checked?'inline':'none');"

...assuming "theID" is the ID of your input field.

adni18

1:56 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<script language=javascript>
function s(ob)
{
if(ob.checked==1){document.getElementById('issince').style.visibility='visible'}else{document.getElementById('issince').style.visibility='hidden'}
}
</script>

<input type=radio name=collection> current week <br>
<input type=radio name=collection checked> current month<br>
<input type=radio name=collection> to date<br>
<input type=radio name=collection onFocus="s(this)" onBlur="s(this)" onClick="s(this)" onChange="s(this)"> since <input type="text" id=issince style="visibility:hidden"><br>

Some minor flaws, but they can be fixed.

cameraguy

9:07 pm on Dec 9, 2004 (gmt 0)

10+ Year Member



Thank you. I will try this.