Variable selected based on dropdown list selection


I found a cascading dropdown list script and its works but im not sure how to pull in the user selection to evaluate in PHP.
I think i need a way to pass the javascript variable to php but not sure how…can someone look at the code below and let me know

not sure if you guys would appreciate me postng someone elses url so ill copy and past the code.


		<form  action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >
			<div style="padding-left:30px; height:710px;">
				<br clear="all" /><br clear="all" />
				<div id="show_sub_categories">
					<select name="search_category" class="parent">
						<option value="" selected="selected">-- Categories --</option>
							foreach($catList->catArrayResults() AS $key1 => $value1)
							{	if($value1['node_parent'] == 0)
								{	echo '<option value="' . $value1['node_inx'] . '">' . $value1['node_name'] . '</option>'; }
				<button name='btn_submit'>send</button
				<br clear="all" /><br clear="all" />

file2.php - code that does the sub category

	{	echo $id = $_REQUEST['parent_id'];
		$count = $catList->categoryCount($id);	
		if($count > 0)
		{	echo '<select name="sub_category" class="parent">
				<option value="" selected="selected">-- Sub Category --</option>';
				foreach($catList->catArrayResults() AS $key2 => $value2)
				{	if($value2['node_parent'] ==  $id )
					{	echo '<option value="' . $value2['node_inx'] . '">' . $value2['node_name'] . '</option>'; }
			echo '</select>';	

javascript code that does the subcategory

$(document).ready(function() {
	$('.parent').livequery('change', function() {
		$('#show_sub_categories').append('<img src="loader.gif" style="float:left; margin-top:7px;" id="loader" alt="" />');
		$.post("get_chid_categories.php", {
			parent_id: $(this).val(),
			var str = $( ".parent" ).serialize(),
		}, function(response){
			setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')", 400);
		return false;
function finishAjax(id, response)
{	$('#loader').remove();

Hi Robin,

At the moment, your form is set to submit the results back to the same script. Is there any PHP code in file1.php that handles the posted form data?

Hi fretburner,

Yes I do but at the moment the code checks to see if the button was clicked and does a few things like check to see if the user completed the selections.

	{	echo 'Button works<br>';
		{	echo 'session=>: '.$_SESSION['currentCategorDropdownListing']; }

to my original problem i decided to sign the var. to a session variable. by passing it to a session variable i was able to fix the problem. not sure if its the best way to fix this problem or not but either case its wroking.