?
Solved

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

Posted on 2015-01-25
2
Medium Priority
?
216 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 2000 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

764 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