954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php function radio

I am making a wordpress plugin but I am having difficulty accessing the results from an array in a function

Radio Box:

<!-- First radio button -->
						<label><input name="posk_options[radio_group_two]" type="radio" value="satellite" <?php checked('satellite', $options['RADIO_GROUP']); ?> /> Satellite</label>

						<!-- Second radio button -->
						<label><input name="posk_options[radio_group_two]" type="radio" value="hybrid" <?php checked('hybrid', $options['RADIO_GROUP']); ?> /> Hybrid</label>
function MY_function ($atts, $content = null) {
       ...
       ), $atts));
       $src = "...ptype=".$RADIO_GROUP."..se";
       return '...';
    }


Ive edited out some of the needless code and just put ... there.
The code above does not work. I am trying to get the result from the radio box to insert further down in the function but I cannot access it. The radio box is selected from an options page and saves succesfully.
So I want $RADIO_GROUP to read satellite or hybrid.
What can I do to read the result from the array and insert it in a different function?
Thanks in advance

Acids
Newbie Poster
9 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

No ideas? I am on abit of a tight schedule here and would really appreciate any help

Acids
Newbie Poster
9 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Hi,
you can use Javascript, more correctly, jQuery:
if you have for example this in your html:

<form>
     <input type="radio" value="button1 name=bg1">MyButton
     <input type="radio" value="button2" name="bg1">MyButton2
</form>


Use this jQuery code to easily retrieve what button from the group was pressed:

$("form :radio").find(":checked").val();


If you print this value you will get either "button1" or "button2" as a result, depending what button was pressed.


Can this help you?

tnjiric
Newbie Poster
21 posts since Jul 2011
Reputation Points: 15
Solved Threads: 2
 

If your $_POST variable is available to your function:
$selected_radio = $_POST['posk_options[radio_group_two]'];

ddymacek
Posting Whiz
317 posts since Jun 2010
Reputation Points: 36
Solved Threads: 64
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: