Jump to content

snowdog

Members
  • Posts

    105
  • Joined

  • Last visited

Everything posted by snowdog

  1. Update: I have completed my php code that ajax will access. I have read tutorials out the wazoo and think I have come up with my ajax call. I need to populate a new drop down with the returned code from the php file. Having a hard time understanding how to get the information out of the returned array and jsdon decoded no to loop through the information and create the drop downs I guess with javascript now? Here is the code so far: Jquery ajax function: <script id="source" language="javascript" type="text/javascript"> jQuery(function () { //----------------------------------------------------------------------- // 1) Send a http request with AJAX //----------------------------------------------------------------------- jQuery.ajax({ url: 'ajax/appointment_ajax_1.php', //the script to call to get data data: "dealer_id = " + jQuery('dealer_id').val(), //you can insert url argumnets here to pass to api.php //for example "id=5&parent=6" dataType: 'json', //data format success: function(data) //on recieve of reply { var first = data[0]; //get firstname var last = data[1]; //get lastname var id = data[2]; //get id //-------------------------------------------------------------------- // 2) Update Dealer's Staff Select Box //-------------------------------------------------------------------- jQuery('#output').html("<option name = 'name' value = "+id+">"+first+" "+last"</option>"); //Set option value and display } }); }); </script> And here is the php file: <?php //-------------------------------------------------------------------------- // php/ajax script for onchange from add appointments //-------------------------------------------------------------------------- session_start(); //-------------------------------------------------------------------------- // 1) Connect to mysql database //-------------------------------------------------------------------------- include("../include/db_connect.php"); //-------------------------------------------------------------------------- // 2) Query database for data //-------------------------------------------------------------------------- // Create container array $dealer_staff_array = array(); $franchise_id = $_SESSION['franchise_id']; $dealer_id = $_POST['dealer_id']; $SQL = "SELECT * FROM login WHERE franchise_id = '$franchise_id' and dealer_id = '$dealer_id' ORDER BY name ASC"; $result = mysql_query($SQL) or die(mysql_error()); while($row = mysql_fetch_array($result)) { //-------------------------------------------------------------------------- // 3) echo result as json string //-------------------------------------------------------------------------- $response = array( 'first' => $row['first'], 'last' => $row['last'], 'id' => $row['id'] ); array_push($dealer_staff_array, $response); } echo json_encode($response); ?> Any help would be appreciated. Thanks Snowdog
  2. I have a dealers select box that when I select it, I then want to load the dealers staff names into the next select box. I have been reading and I have this as the progress in my head. on submit, the ajax needs to send over the dealer_id to a php file that will then do a database query to get the staff members of that dealer_id and send the name and staff_id back to the html page to populate the dealers_staff select box. Once that is done it needs to do it all over again to get the dealers_staff member's name, email address and contact numbers to ill in some text boxes. So I think I understand what has to happen just don't know what to do to make it happen now. Thanks Snowdog
  3. so stupid, the second I had it as $nbsp; always something stupid I over look. Thanks Everyone.
  4. 108 while($run = mysql_fetch_array($result)) 109 { 110 111 echo("<tr><td> $run['vinNumber'] </td><td> $run['carYear'] $nbsp; $run['carModel'] </td><td><img src='franchises/franchise_id_{$franchise_id}/lotImages/dealer_id_{$dealer_id}/lot_id_{$run['id']}/wheelFL.jpeg'></td></tr>"); 112 113 }
  5. Here is my error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/vhosts/bookawrs.com/httpdocs/lot.php on line 111 Here is part of the code giving me the problems $SQL = "SELECT * FROM lot WHERE franchise_id = '$franchise_id' and dealer_id = '$dealer_id' ORDER BY id ASC"; $result = mysql_query($SQL) or die(mysql_error());[/size][/font][/color] [color=#000000][font='Times New Roman'][size=1]while($run = mysql_fetch_array($result)) {[/size][/font][/color] [color=#000000][font='Times New Roman'][size=1]echo("<tr><td> $run['vinNumber'] </td><td> $run['carYear'] $nbsp; $run['carModel'] </td><td><img src='franchises/franchise_id_{$franchise_id}/lotImages/dealer_id_{$dealer_id}/lot_id_{$run['id']}/wheelFL.jpeg'></td></tr>");[/size][/font][/color] [color=#000000][font='Times New Roman'][size=1]}
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.