Solved

I'm Trying to get the value of the HTML Select

Posted on 2015-01-25
2
208 Views
Last Modified: 2015-01-26
I have 2 select drop down windows … populated with our database id and name … you select the first golf club brand from the list and I need to capture that value and pass it to the next </select> and database query

please see my code below
                       
<script>
                        $( ".target" ).change(function() {
			var raq_id = $(this).val();
			 alert (raq_id);
			});
			</script>
                        $sql3 = 'SELECT * FROM racquets WHERE branch = rac_id';

Open in new window

<?php
							$conn = new mysqli($servername, $username, $password, $dbname) or die("Connection Failed");
							//$dbname = ("mydev")or die("Connection Failed");
							$sql = "SELECT * FROM racquet_branch";
							$result = $conn->query($sql);
							?>
							<select name="Select_Brand" class="target" id = "raq_brand" name="racquet_brand" style="align-left:250%; width:100%;border:1px solid #CDCDCD;width:302px !important;">
							<?php
							while($row = $result->fetch_assoc()) {
							?>
							<option value="<?php echo $row["id"];?>"> <?php echo $row["name"];?> </option>
							 
							<?php
							}
							?>
							<script>
                           $( ".target" ).change(function() {
								var raq_id = $(this).val();
							  alert (raq_id);
							});
							</script>
							<?php							
							$conn2 = new mysqli($servername, $username, $password, $dbname) or die("Connection Failed");
							//$dbname = ("mydev")or die("Connection Failed");
							$sql3 = 'SELECT * FROM racquets WHERE branch = rac_id';
							$result3 = $conn2->query($sql3);
							?>
							<select name="Select_Model" class="target" id = "raq_brand" name="racquet_brand" style="align-left:250%; width:100%; border:1px solid #CDCDCD;width:302px !important;">
							<?php
							while($row2 = $result3->fetch_assoc()) {
							
							?>
							<option value="<?php echo $row2["name"];?>"> <?php echo $row2["name"];?> </option>
							 
							<?php
							}
							?>
							</select>

Open in new window

0
Comment
Question by:dolamitejenkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 40569614
The better way woulb usingAjax to call the php script which executes the query and return the reult to hte javascript to display data.
Bua the simplest way is this:

<script>
                        $( ".target" ).change(function() {
			var raq_id = $(this).val();
			 alert (raq_id);
                         window.location.href = 'php_script.php?raq_id=' + raq_id;
			});
			</script>

Open in new window

I didn't test it, but it should be possible redirect to the same page, checking $_GET array as usual.
0
 

Author Closing Comment

by:dolamitejenkins
ID: 40571003
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question