jwk811 Posted November 6, 2006 Share Posted November 6, 2006 could i just do something in a script with javascript and make a variable called either true or false and then use it in my php code? like say i have a form and there is two radio button options and once someone clicks one i have javascript check which one they clicked and if they clicked the first one javascript would make a variable called true and falses for the other option. then i can take that variable and use it to display a different set of options if its true and another set if its false. am i on the right track? can this work? how can i do this? and am i making any sense? lol Quote Link to comment Share on other sites More sharing options...
Telemachus Posted November 6, 2006 Share Posted November 6, 2006 Well you can't actually name the variable true or false, but if you have two radio buttons with the same name but unique ids, say true and false, you can just assign it like [code]var isTrue = document.getElementById("true").checked;[/code]you could also validate it easily[code]var isFalse = document.getElementById("false").checked;if (!isTrue && !isFalse){ alert("Please choose true or false."); return false;}[/code]( document.myFormName.myRadioName[0] and document.myFormName.myRadioName[1] would probably actually be compatible with more browsers, but it's just an example. )Using it in the PHP coding is exactly the type of thing I need to learn, so I can't be any help there. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 6, 2006 Share Posted November 6, 2006 You should be able to do all of this in JS. 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.