troubleshooting Question

Get value of drop-down when there are multiple of them

Avatar of Jazzy 1012
Jazzy 1012 asked on
JavaScriptHTMLPHP
6 Comments1 Solution98 ViewsLast Modified:
I have this code:
  <div class="adddiv">
				     <p class="deliveryText OldStandard">Delivery </p>
						<form>
						<p class="delivery_days">Monday
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
						 </p>
						<select class='mondaySelect'  MondayOption= "<?php echo $new_counter;?>">
						<?php
						for($i=0;$i <= $qty_value; $i++)
						{
						echo '<option value="'. $i.'">'. $i .'</option>';
						}
						?>
						</select>
						
						<p class="delivery_days">Wednesday &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>	
						<select class='wednesdaySelect' WednesdayOption= "<?php echo $new_counter;?>">
						<?php
						for($i=0;$i <= $qty_value; $i++)
						{
						echo '<option value="'. $i.'">'. $i .'</option>';
						}
						?>
						</select>
						
						<p class="delivery_days">Friday &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p>	
						<select class='fridaySelect' FridayOption= "<?php echo $new_counter;?>">
						<?php
						for($i=0;$i <= $qty_value; $i++)
						{
						echo '<option value="'. $i.'">'. $i .'</option>';
						}
						?>
						</select>
						</form>
						<p class="meal_price priceInDiv">$<?=$new_price/100?></p>
						<a class = "confirmbtn" onclick='post(<?=$new_id?>,"0")'>CONFIRM</a>
				   </div>

<script>
  function post(mealId,uid){
		var protein = $('.option-selected').attr('label_option');
		var mondayOption = $('.mondaySelect').find('option:selected').attr("MondayOption");
		alert(mondayOption);
		var wednesdayOption = $('.wednesdaySelect :selected').attr('WednesdayOption').val();
		var fridayOption = $('.fridaySelect :selected').attr('FridayOption').val();
		if(mondayOption ==0 && wednesdayOption ==0 && fridayOption ==0){
			$('#day_null').show();
			//alert("You must select aday");
		}else{  
	       
						
				    $.ajax({
				    	method: "POST",
				        url: "/order/createSession",
				        data: { meal:mealId,protein:protein,monday:mondayOption,wednesday:wednesdayOption,friday:fridayOption},
				        success:function(){
				        	location.reload();
							
				        }
				    	})
				
			}
	  }

</script>

I want to be able to get the value of the select box, but its not working for some reason. the reason I want to do it through the attribute it because, there are multiple selections in a while loop and i had to differenate them by that way. But im open to any ideas, there are a total of 9 loops so 9 select boxes.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros