Show only one option for each select

<table>
	<tr>
		<td>
			Search By
		</td>
		<td>
			<select id="selection" onchange="show_field()">
				<option value='null'>Select One</option>
				<option value='emp'>Employment</option>
				<option value='post'>Posting Place</option>
				<option value='member'>Membership</option>
				<option value='branch'>Branch</option>
			</select>
		</td>
	</tr>
	<tr id='emp' class="selection_class" style="display:none">
		<td>
			Employment
		</td>
		<td>
			<select id="selection" >
				<option value='null'>Select One</option>
				<?php 
								foreach($employmentStatus as $branch)
								{
									echo "<option value='$branch->EmployementStatus'>$branch->EmployementStatus</option>";
								}
							?>
			</select>
		</td>
	</tr>
	<tr id='post' class="selection_class" style="display:none">
		<td>
			Posting Place
		</td>
		<td>
			<select id="selection" >
				<option value='null'>Select One</option>
				<?php 
								foreach($postingPlace as $branch)
								{
									echo "<option value='$branch->PostingPlace'>$branch->PostingPlace</option>";
								}
							?>
			</select>
		</td>
	</tr>
	<tr id='member' class="selection_class" style="display:none">
		<td>
			Membership
		</td>
		<td>
		<select name="CatagoryMembership">
							<option value='null'>Select one</option>
							<option value="life">Life Member </option>
							<option value="general">General Member </option>
						</select>
		</td>
	</tr>
	<tr id='branch' class="selection_class" style="display:none">
		<td>
			Branch
		</td>
		<td>
			<select name="Bracnhname">
							<option value='null'>Select one </option>
							<?php 
								foreach($result as $branch)
								{
									echo "<option value='$branch->branch_id'>$branch->branch_name</option>";
								}
							?>
						</select>
		</td>
	</tr>
	<tr id='sbmit' style="display:none">
		<td>
			
		</td>
		<td>
			<input type="submit" value="Run Report"/>
		</td>
	</tr>
</table>
<div>

<script>
	function show_field()
	{
		var field = $('#selection option:selected').val();
		if (field == 'null') return false;
		$('.selection_class').hide();
		$('#'+field).show();
		$('#sbmit').show();
	}
</script>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s