mysql - Pass a value to my function in php -


i have list of products in table extracted db. each product have field aliquota (= vat, tax). want have possibility modify aliquote value assigned single products.

i did drop menu next actual aliquote contains allowed value aliquote table of database. (that values 0.00, 4.00, 10.00, 20.00). once selected, value inserted in readonly input text field id "aliquota_xxx" (where xxx id correspond product). want save value pressing button confirm vat activate function save_modify (this function exists in project). code:

<select class="piccolo elemento_modulo_obbligatorio" id="aliquota_dropdown_<?php echo $row['rid']; ?>" name="aliquota_dropdown"> <?php  $aliquote = "select aliquota,id aid aliquote order aliquota asc"; $result_aliquote = mysql_query($aliquote) or die("invalid query: " . mysql_error()); while ($row_aliquote = mysql_fetch_array($result_aliquote)) { echo '<option onclick=\''; ?>  $("#aliquota<?php echo $row['rid']; ?>").val("<?php echo $row_aliquote['aliquota']; ?>");  <?php echo ';\' value="' . $row_aliquote['aid'] . '">' . $row_aliquote['aliquota'] . '</option>'; } ?>  </select>  <input autocomplete="off" type="text" class="class12" id="aliquota<?php echo $row['rid']; ?>" name="aliquota" readonly="readonly" value="" /> <input type="button" onclick="save_modify(&quot;aliquota&quot;,document.getelementbyid('aliquota_<?php echo $row['rid']; ?>').value,<?php echo number_format($row['aliquota'],2,".",","); ?>);" value="confirm vat" /> 

the function save_modify that:

function save_modify(cosa, valore_nuovo, valore_vecchio) {     $.ajax({         type: "get",         url: "ajax_salva_modifica_valore.php",         data: "id_documento=" + <? php echo $_get['id_documento']; ?> +"&cosa=" + cosa + "&id=" + id + "&valore_nuovo=" + valore_nuovo + "&valore_vecchio=" + valore_vecchio,         cache: false,         success: function(data) {             $("#sezione_messaggi").html("succesfully modified!");         },         beforesend: function() {             $("#sezione_loading").html("<img src='../images/ajax-loader.gif' />");         },         complete: function() {             $("#sezione_loading").html("");             post_modifica(id);             carica_righe();         }     }); } 

and part of ajax_salva_modifica_valore.php interest is:

<?php session_start(); $cosa = $_get['cosa']; $array_id = split("_",$id); $id_riga = $array_id[1];   $valore_nuovo = $_get['valore_nuovo']; $valore_vecchio = $_get['valore_vecchio'];  if($cosa == "aliquota") {     $modifica = "update righe_documenti                  set aliquota = '" . $valore_nuovo . "'                  id = " . $id_riga;     $result = mysql_query($modifica) or die("invalid query: " . mysql_error());  } ?> 

i don't know problem, because parameter passed function correct, modify it's not applied...

someone can me fix or try solution?

the save_modify , ajax_salva_modifica_valore.php not made me, suppose them correct (and works edit of other products information...)

thanks!

the main problem number_format() formats number string , should enclosed in double quotes (&quot;) in case.

<input type="button" onclick="save_modify(&quot;aliquota&quot;,this.id,$(&quot;#aliquota<?php echo $row['rid']; ?>&quot;).val(),&quot;<?php echo number_format($row['aliquota'],2,",","."); ?>&quot;);" value="confirm aliquota" /> 

however looking @ rest of code, seems don't need number_format() @ all:

<input type="button" onclick="save_modify(&quot;aliquota&quot;,this.id,$(&quot;#aliquota<?php echo $row['rid']; ?>&quot;).val(),<?php echo $row['aliquota']; ?>);" value="confirm aliquota" /> 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -