Jump to content


Photo

Chained Form Events


  • Please log in to reply
2 replies to this topic

#1 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 24 May 2006 - 02:33 PM

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.

<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


#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 May 2006 - 02:58 PM

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...
<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>


#3 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 24 May 2006 - 03:12 PM

get me started?!?!! you did all the legwork, it's practically done. thanks brutha.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users