Php, jquery and forms

I have a multi-part form that give the user the choice of two options for a section of step 2 using form buttons. The option chosen is revealed using jquery. I am trying to pick up on the choice of option using php (and ultimately store it in my database) but it is not picking up the button value at all.

My variables are carried from step to step using sessions with the following code:

 
// process the $_POST variables and save them in the $_SESSION array  
foreach ($_POST as $key => $value) {
    // assign to temporary variable and strip whitespace if not an array
    $temp = is_array($value) ? $value : trim($value);
	// assign to a variable of the same name as $key
	$_SESSION[$key] = $temp;
}
?>

I have no issues picking up the values of the other form elements.

The jquery I used is

// script used to hide or show the form for option one
	$(document).ready(function() {
		$('.optionOneForm').hide();
		$('<input type="button" name="ad_option" class="revealer" value="Choose Option 1" />')
		.insertBefore('.optionOneForm');
		$('.revealer').click(function(){
			$('.revealer').hide("medium", "swing");
			$('.options').hide("medium", "swing");
			$(this).next().fadeIn("slow", "swing");
		});
		$('.return').click(function() {
			$('.optionOneForm').hide();
			$('.revealer').show("medium", "swing");
			$('.options').show("medium", "swing");
		});
	});

With minor changes, this is the same code I used for option 2. (In this post I keep getting a button instead of the actual code for the button … ??)
Can anyone see why I can’t get the value of my ‘ad_option’ ?

You are not showing all the code involved so we have to guess.

My guess #1 is you are using JS to submit the form through jQuery and the form value is not being picked up because while you assign a name=ad_option there is no corresponding id=ad_option so JQuery is not able to find it.

Just give the form a straight forward submit button, disable the JS and get the form working so you know for sure the HTML form element data is being passed to PHP in exactly the format you want, then, progressively add JS to do the fancy show/hiding.

Sorry I was so late responding … a weekend got in the way. I can’t give you all the code, but I will try what you suggested. Thank you.