| Autor | Zpráva | ||
|---|---|---|---|
| juraj Profil |
#1 · Zasláno: 14. 6. 2012, 14:36:13
Zdravim
tento kod som nasiel na nete,ako sa prenesie id do php skripta? <script type="text/javascript">
$(document).ready(function () {
function slideout() {
setTimeout(function () {
$("#response").slideUp("slow", function () {});
},
2000);
}
$(".inlineEdit").bind("click", updateText);
var OrigText, NewText;
$(".save").live("click", function () {
$("#loading").fadeIn('slow');
NewText = $(this).siblings("form").children(".edit").val();
var id = $(this).parent().attr("id");
var data = '?id=' + id + '&text=' + NewText;
$.post("update.php", data, function (response) {
$("#response").html(response);
$("#response").slideDown('slow');
slideout();
$("#loading").fadeOut('slow');
});
$(this).parent().html(NewText).removeClass("selected").bind("click", updateText);
});
$(".revert").live("click", function () {
$(this).parent().html(OrigText).removeClass("selected").bind("click", updateText);
});
function updateText() {
$('li').removeClass("inlineEdit");
OrigText = $(this).html();
$(this).addClass("selected").html('<form ><textarea class="edit">' + OrigText + '" </textarea> </form><a href="#" class="save"><img src="images/save.png" border="0" width="48" height="15"/></a> <a href="#" class="revert"><img src="images/cancel.png" border="0" width="58" height="15"/></a>').unbind('click', updateText);
}
});
</script><div id="response"></div>
<ul>
<?
$sql12 = sprintf("SELECT id,firstname
FROM users");
$res1 = @mysql_query($sql12);
$num1 = @mysql_num_rows($res1);
while(list($id,$firstname) = @mysql_fetch_row($res1)) {
?> <?php echo $id;?>
<li class="inlineEdit" id="<?php ECHO $id;?>">
<?php echo $firstname;?>
?</LI>
<?}?></ul>vypise mi zoznam z db a chcem aby sa id prenieslo do update.php skriptu.Z text arey to funguje ale id sa nechce preniest.kod v php update.php
<?php
include('conn.php');
$id = mysql_escape_string($_POST['id']);
$sql="UPDATE users SET firstname='$text' WHERE id='$id'";
$result=mysql_query($sql);
?> |
||
| _es Profil |
#2 · Zasláno: 15. 6. 2012, 07:36:55
juraj:
Preštuduj si oficiálnu dokumentáciu pre metódu jQuery.post (http://api.jquery.com/jQuery.post/) a prídeš na to, čo robíš zle. |
||
|
Časová prodleva: 14 let
|
|||
0