Ninjakreborn Posted February 23, 2007 Share Posted February 23, 2007 Is there an easy way to make a select form only be able to select 1 field. For instance. 3 select boxes, but only 1 of them can be selected at a time. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted February 23, 2007 Share Posted February 23, 2007 you can write a javascript function such as function swapColDel() { if (document.getElementById("col").checked == true) { document.getElementById("del").checked = false } if (document.getElementById("del").checked == true) { document.getElementById("col").checked = false } } you will need to modify that code for your check boxes but basically what happens is in the onlclick of each checkbox this function is run and if one is selected the other one is deselected Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 23, 2007 Author Share Posted February 23, 2007 Perfect, I deleted that and started with radio buttons hten. last question, how do you hide text when a radio button is selected. If this needs to be moved, go for it. Quote Link to comment Share on other sites More sharing options...
Scriptor Posted February 23, 2007 Share Posted February 23, 2007 If the hide is in an html element with an id use this js function: function hide(id){ document.getElementById(id).style.display='none'; } Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 23, 2007 Author Share Posted February 23, 2007 Ok, then how do you make it re-appear. That will make it disappear, how do you make it re-appear. Quote Link to comment Share on other sites More sharing options...
divinecoder Posted February 23, 2007 Share Posted February 23, 2007 function show(id){ document.getElementById(id).style.display='block'; } Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 23, 2007 Author Share Posted February 23, 2007 Ah ok, I had to use inline for my purpose. I am not use to working with styles in Javascript, thanks. it's very rare I ever have to change styles with it. Quote Link to comment Share on other sites More sharing options...
Stopofeger Posted February 25, 2007 Share Posted February 25, 2007 There is a better "suggested" solution then using display as the display property removes the element from the document flow completely. use visibility. document.getElementById("id").style.visibility It will not remove the element completely but just will make it invisible. 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.