
smallzoo
Members-
Posts
21 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
smallzoo's Achievements

Newbie (1/5)
0
Reputation
-
Sorry for the dumb reply but I'm not sure what you mean I put the var_dump in the called php file (modajustments), ran the script from the calling page but I dont see any response. All the ajax request does is run ( I presume ? ) close the popup and then return to the calling page ? Cheers
-
if(isset($_POST['defid'])) { foreach($_POST['defid'] as $did) { $conn->query($sql="INSERT INTO modified_adjustments (default_id) VALUES (:did)", $params=array(':did'=>$did)) ; } } Made no difference ?
-
I have tried arrays and explicit i.e. defid_1,defid_2 and defid[1],defid[2] and running the modajustents.php on its own works great BUT from the ajax request nothing happens ie modadjustments.php?defid%5B1%5D=5&defid%5B2%5D=6&defid%5B3%5D=8 works great but using the ajax request and sending that form data doesn't !
-
..sorry made a mistake and hit send by accident Anyway..made some alterations to the code function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); } formData is "defid_1=5&defid_2=6&defid_3=8” mod adjustments.php code is $i=1; $conn->query($sql="DELETE FROM modified_adjustments where default_id<>''"); while (isset($_GET["defid_".$i])){ $did= $_GET["defid_".$i]; $conn->query($sql="INSERT INTO modified_adjustments (default_id) VALUES (:did)", $params=array(':did'=>$did)) ; $i++; } If I run this using ...modadjustments.php?defid_1=5&defid_2=6&defid_3=8 the three records are inserted !! Success BUT If I use the ajax.request function they are not Any Clues
-
Made some alterations to the form data so now sends distinct data:- function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
Made some alterations to the form data so now sends distinct data:- function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
ok..finally I think I m getting there <? $c=0; foreach($adjustments as $a) { $i=0; $c++; ?> <input style="width: 20px;float: none;" type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[<?php echo $c;?>]" id="defid[<?php echo $c;?>]" /> <? } ?> This gives me ( in debug mode ) <input style="width: 20px;float: none;" type="checkbox" checked value="5" name="defid[1]" id="defid[1]" /> ...... <input style="width: 20px;float: none;" type="checkbox" checked value="6" name="defid[2]" id="defid[2]" /> ...... <input style="width: 20px;float: none;" type="checkbox" checked value="8" name="defid[3]" id="defid[3]" /> so running the script function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); alert(formData); new Ajax.Request("/views/releases/modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); } gives me defid%5B1%5D=5&defid%5B2%5D=6&defid%5B3%5D=8 as the form data ...so how do I get these defid values in the mod adjustments php file ?
-
great thanks is there a way of seeing wha happens at modadjustments.php As its async I can't see what happens before it returns ?
-
Ok.. so like this <? foreach($adjustments as $a) { $i=0; ?> <input style="width: 20px;float: none;" type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[<?=$i?>]" id="defid[<?=$i?>]" /> <? } ?> and function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); //data = new FormData(); alert(formData); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
I mean GET sorry yes I forgot the fd=.. that was for testing Not sure what you mean by empty post.. it posts the form data When I use the correct function ( see below ) function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); alert(formData); new Ajax.Request("/views/releases/modadjustments.php?"+formData, { method:'post', onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); } and also add the [] parameter to the form variable ( see below ) ‘ cut down version <form name="modadjustments" id="modadjustments" action="" onsubmit="return false;"> <? foreach($adjustments as $a) { $i=0; ?> <input type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[]" id="defid[]" /> <? } ?> <button type="button" onclick="modifyAdjustments();">Save changes</button> </form> the format still looks like this ( see below ) defid%5B%5D=5&defid%5B%5D=6&defid%5B%5D=8
-
Tried this.. got nothing.. what am I doing wrong ? ....../modadjustments.php?defid=5&defid=6 <?php print_r("start loop"); foreach ($_POST['defid'] as $value) { print_r($value); } print_r("end loop"); ?> just get start loopend loop
-
I have a function which posts data from a form ( a table.. ) function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("/views/releases/modadjustments.php?fd="+formData, { method:'post', onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); } When I look the form data it looks like this ;- "defid=5&defid=6&defid=2" All I want modadjustments.php to do is to parse this data and do a foreach loop so I can do something with the defid's e.g. e.g. foreach...{ print_r (defid) } this will show of above example 5 6 7 I'm going mad with trying to do this ?