View Full Version : display div with radio buttons
sendjunk
04-04-2014, 01:20 PM
I would like to have 2 radio buttons on one page "ON" and "OFF" and when "ON" is selected contents of a div is displayed on another page. When the user selects "OFF" the div contents goes away..
Can anyone help..I have searched and found something simmilar http://jsfiddle.net/3sdk8/1/ but i dont know how to set it up..on two pages
Thank you for any help
jscheuer1
04-04-2014, 02:17 PM
The jsfiddle you linked to is in javascript. But you have posted in the PHP forum.
Do you want a javascript or a PHP solution?
When you say "another page", do you mean another page that is loaded from the page with the radio buttons, or another page that's already open in the browser?
sendjunk
04-04-2014, 02:27 PM
Thank you for the quick reply ... OK, I have an admin page and a customer page...on the admin page I would like to have the radio buttons and when selected the content to be displayed on the customer page... I dont have a preference of PHP or JavaScript... any help is appreciated ..
jscheuer1
04-05-2014, 12:26 PM
I take it that the admin page's access is limited to just you and/or someone else running the site. And the customer page would be viewed by an at least potentially larger audience. If so you could, using javascript and PHP, have the act of checking a radio write/overwrite a file on the server. Then, as the customer page loads it could, using just PHP, check the contents of the file that was written to see what state the radio buttons last had and on that basis show or not show certain content to the customer, also - when the admin page next loads it could also read the file, to know which radio should currently be checked. If this is the situation and sounds like what you're after, I will make you some sample pages to show you how to do that.
Keep in mind that the admin page would not be able to change* the customer page if it was currently being viewed by a client when a different radio was checked. But the next time anyone viewed the customer page or if the current person were to refresh it, that would then change whether or not it would show this optional content.
The optional content could be on the customer page, or in a separate file. Regardless of where it's kept, it could not be seen unless the radio on the admin page that determines its state that allows it to be seen is checked. Otherwise it would be hidden by PHP, which would require server access to see it.
*It could, if the customer page were to be actively polling for a change in the flag file. However, that would require the client viewing the customer page to have javascript enabled. You cannot count on that unless you deny access to the customer page unless the client has javascript enabled. Even then, someone might be able to get around that.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.