Results 1 to 2 of 2

Thread: I want to change select value samilar to other select value

  1. #1
    Join Date
    Jul 2014

    I want to change select value samilar to other select value

    I want to change <select> values samiler to other select value
    for example
    I choise honda from <select id="car"> got new values in <select id="model"> 1) civic 2) accord 3) ... etc
    and these models in database
    here my code

    HTML Code:
    <script type="text/javascript">
    	$(document).ready(function() {
        $("#make").change(function() {
    		var val = $(this).val();
    		$result = mysqli_query($americacon,"SELECT * FROM cars WHERE make = val");
    		while($row = mysqli_fetch_array($result)) {
    		  $("#model").html("<option value='<?php echo $row['model']; ?>'><?php echo $row['model']; ?></option>");
    <select id="make">
    <option value="honda">honda</option>
    <option value="golf">Golf</option>
    <select id="model">
    sorry for my english

  2. #2
    Join Date
    Feb 2014
    Managua, Nicaragua
    I recomend you to use ajax to get data from a database... You can not pass info or variables from js to php as you did. Var val does not exist when you do the query.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles