Jump to content

How to hide 'radio' button


imimin

Recommended Posts

why do you need it be invisible?

<input type="radio" name="Radio" value="1" id="Radio1" style="display:none;">

to undo the hide:

<a href="javascript:void();" onClick="document.getElementById('Radio1').style.display='';">Show</a>

Link to post
Share on other sites

Thanks! I have a single item I need to display that needs to be passed to a shopping cart.  I don't want the radio button to be displayed in someones face with no other option.  Thanks for your help.

Link to post
Share on other sites

well, as long as what we gave you helped... I guess it works. But if your outputting the selection with php, wouldn't it be easier/more logical to simply not output the other radio boxes if they don't have options?

If you want to present to the user that there is sometimes options, but not in this case, you can disable the options.

One:<input type="radio" name="Radio" value="1" id="Radio1"><br>
Two:<input type="radio" name="Radio" value="2" id="Radio1" disabled><br>
Three:<input type="radio" name="Radio" value="3" id="Radio1" disabled>

Link to post
Share on other sites

You don't want it displayed for usability/aesthetic reasons, right?  The CSS and JS solutions given are fine if that's all it is, but if there's a security issue involved keep in mind that the user can always get around the css and js by disabling them in their browser.

Link to post
Share on other sites

JavaScript solutions to this is a bad idea. CSS is good. Who would disable CSS just for that? I mean they would literally be looking at black text with white background.

Link to post
Share on other sites

A correctly programmed script will not be vulnerable. Remember - if the checkbox is disabled/invisible, that means the user can't change/shouldn't change the data. You could easily store that information as a session, and just let it pass from the first page to the third page without a problem. Do not allow the php script to "redetermine" the checkbox value. This is a possible security risk.

 

If you're using js or css, make sure you have: disabled="disabled" within the input tag. A user can't disable html or change the syntax.

Link to post
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.