Jump to content

Chained Form Events


pgsjoe

Recommended Posts

Not sure if it's suppose to be Javascript driven or PHP but here's what I want to do.

I have two radio buttons on a form. "Member" and "NONmember". If they check "Member" I wanted to do that cool little thing where a field would then pop up asking for their member number, but that field is not there unless they "check" that particular button, and then if it's not clicked it goes away.

My guess is Javascript, something along the lines of an onClick="return(memberyes)"; I'm just not versed enough in it to write it. But, if there's a PHP way, that'd be awesome. Thanks in advance.

- JoE -

------------------------------------
tried this so far with no luck.

[code]<script type="text/javascript">
function member(yes) {
    var thisform=document.semfest;
        if (thisform.member[1].checked)
            print ('<tr>
      <td>if member, member #:  </td>
      <td><input name="membernumber" type="text"></td>
    </tr>');
    }
</script>

<input name="member" type="radio" value="member" onClick="return member(yes)">
Member

<input name="member" type="radio" value="NONmember">
NonMember[/code]
Link to comment
https://forums.phpfreaks.com/topic/10351-chained-form-events/
Share on other sites

No, this can't be done with PHP unless you refresh the page. I'd recommend you go with JavaScript. Heres a little something to get you on your way...
[code]<input type="radio" name="member" value="yes" onclick="showfield('yes')"/> Member<br/>
<input type="radio" name="member" value="no" onclick="showfield('no')"/> Not Member<br/>
<input type="text" name="memberid" id="memberid" style="visibility:hidden;"/>

<script type="text/javascript">
function showfield(x) {
    switch(x) {
        case "yes":
            document.getElementById("memberid").style.visibility = "visible";
            break;
        case "no":
            document.getElementById("memberid").style.visibility = "hidden";
            break;
    }
}
</script>[/code]
Link to comment
https://forums.phpfreaks.com/topic/10351-chained-form-events/#findComment-38588
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.