AJAX - Enviar multiple SELECT??

 
Vista:
Imágen de perfil de miguel
Val: 1
Ha aumentado su posición en 9 puestos en AJAX (en relación al último mes)
Gráfica de AJAX

Enviar multiple SELECT??

Publicado por miguel (1 intervención) el 14/11/2017 20:03:25
Hola a todos quisiera preguntarles como puedo insertar un multiple select usando AJAX y PHP?

ya que mi codigo lo unico que hace es enviar un valor y los otros los ignora :/


alguien gusta orientarme? o darme un tip? jeje oh ya si deplano ayudarme? gracias este es mi codigo !!

Select
1
2
3
4
5
6
7
8
9
10
11
<select class="form-control" id="ids" name="ids">
                     <option>Seleccione:</option>
                     <?php
						  $mysqli = new mysqli('localhost', 'root', '1234', 'reach_v1');
						  $query = $mysqli -> query ("SELECT id_sus, name_sus, casnum_sus FROM sustance");
						  while ($valores = mysqli_fetch_array($query)) {
							echo '<option value="'.$valores[id_sus].'">'.$valores[casnum_sus].'</option>';
						  }
						 mysqli_close($mysqli);
						?>
                 </select>

Ajax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<script type="text/javascript">
$( document ).ready(function() {
	var grid = $("#det_grid").bootgrid({
		ajax: true,
		rowSelect: true,
		post: function ()
 
		{
			/* To accumulate custom parameter with the request object */
			return {
				id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
			};
		},
 
		url: "Response/response -det.php",
		formatters: {
		        "commands": function(column, row)
		        {
		            return "<button type=\"button\" class=\"btn btn-xs btn-warning command-edit\" data-row-id=\"" + row.id_detsus + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " +
		                "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-row-id=\"" + row.id_detsus + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>";
		        }
		    }
   }).on("loaded.rs.jquery.bootgrid", function()
{
    /* Executes after data is loaded and rendered */
    grid.find(".command-edit").on("click", function(e)
    {
        //alert("You pressed edit on row: " + $(this).data("row-id"));
			var ele =$(this).parent();
			var g_id = $(this).parent().siblings(':first').html();
            var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
console.log(g_id);
                    console.log(g_name);
 
		//console.log(grid.data());//
		$('#edit_model').modal('show');
					if($(this).data("row-id") >0) {
 
                                // collect the data
                                $('#edit_id').val(ele.siblings(':first').html()); // in case we're changing the key
                                $('#edit_det').val(ele.siblings(':nth-of-type(2)').html());
 
 
 
					} else {
					 alert('Now row selected! First select row, then click edit button');
					}
 
    }).end().find(".command-delete").on("click", function(e)
 
    {
 
		var conf = confirm('Delete ' + $(this).data("row-id") + ' items?');
					//alert('Deleted succesful');
 
                    if(conf){
                                $.post('Response/response -det.php', { id: $(this).data("row-id"), action:'delete'}
                                    , function(){
                                        // when ajax returns (callback),									
										$("#det_grid").bootgrid('reload');
 
                                });
								//$(this).parent('tr').remove();
								//$("#det_grid").bootgrid('remove', $(this).data("row-id"))
                    }
    });
});
 
function ajaxAction(action) {
				data = $("#frm_"+action).serializeArray();
				$.ajax({
				  type: "POST",
				  url: "Response/response -det.php",
				  data: data,
				  dataType: "json",
				  success: function(response)
				  {
					$('#'+action+'_model').modal('hide');
 
					$("#det_grid").bootgrid('reload');
				  }
				});
			}
 
			$( "#command-add" ).click(function() {
			  $('#add_model').modal('show');
			});
			$( "#btn_add" ).click(function() {
			  ajaxAction('add');
			});
			$( "#btn_edit" ).click(function() {
			  ajaxAction('edit');
			});
		$("#det_grid").bootgrid({
    searchSettings: {
        delay: 100,
        characters: 3
    }
});
});
 
</script>

PHP
1
2
3
4
5
6
7
8
9
function insertVendor($params) {
		$data = array();;
		$sql = "INSERT INTO `det_sus` (id_prod,id_sus)
		VALUES('" . $params["idp"] . "','" . $params["ids"] . "');  ";
 
		echo $result = mysqli_query($this->conn, $sql) or die("error to insert employee data");
 
 
	}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder