jwk811 Posted November 5, 2006 Share Posted November 5, 2006 i want to have a form that has two options using radio buttons and depending on which ever they pick a set of new options would show up.. i was told that this could be done by hiding and showing <div>s but im not sure how i can do that.. so if anyone could please show me how that would be great Quote Link to comment Share on other sites More sharing options...
php_joe Posted November 5, 2006 Share Posted November 5, 2006 It sounds like what you want is JavaScript's onclick function.Joe Quote Link to comment Share on other sites More sharing options...
tomfmason Posted November 5, 2006 Share Posted November 5, 2006 You will need to do someting like this..Javascript[code]function showHideDiv() { var div = document.getElementById('yourDiv').style; if (div.visibility == 'visible') { div.visibility = 'hidden'; } else { div.visibility = 'visible'; } }[/code]Now you will have to define the visibility state in the div it's self for this to work..Like this.[code]<div id="yourDiv" style="visibility:hidden;">Something here</div><a href="#" onclick="showHideDiv();">Click to show/hide the div</a>[/code]You can also use display.. Like this.[code]function showHideDiv() { var div = document.getElementById('yourDiv').style; if (div.display == 'block') { div.display = 'none'; } else { div.display = 'block'; }}[/code]Hope that helps,Tom Quote Link to comment Share on other sites More sharing options...
fenway Posted November 5, 2006 Share Posted November 5, 2006 Note that display actually removed this DIV from the flow, whereas visibility simply "hides" it. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted November 5, 2006 Author Share Posted November 5, 2006 how would i do it using the onClick thing? Quote Link to comment Share on other sites More sharing options...
tomfmason Posted November 5, 2006 Share Posted November 5, 2006 onclink="showHideDiv('yourid');" Quote Link to comment Share on other sites More sharing options...
jwk811 Posted November 5, 2006 Author Share Posted November 5, 2006 how can i set that up using radio buttons. the code above would work with check boxes but now im stuck playing around with the code to get it to work for the buttons. can you see what my problem would be? if there was like an offclick thing when the button goes to a different one it would work Quote Link to comment Share on other sites More sharing options...
jwk811 Posted November 5, 2006 Author Share Posted November 5, 2006 im gettin somewhere Quote Link to comment Share on other sites More sharing options...
fenway Posted November 6, 2006 Share Posted November 6, 2006 offclick? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.