1
私はいくつかの助けが必要です。私はPHP変数からjqueryスクリプトにどのように値を渡すことができますか? 私がやっていることは、mysqlブラウズから作成された要素のリストからモーダルウィンドウを開くことです。そのため、アンカーに可変値を渡す必要があります。 は、ここに私のコードです:PHPからjqueryへの値渡し
<?php
$query_tours = "Select * from tours where feautured = 'Y' " ;
$result_tours = mysql_query($query_tours);
while($row=mysql_fetch_array($result_tours)) {
$tourID = $row['recid'];
$tit_esp = $row['tit_esp'];
$adrate = $row['ad_rate'];
$chrate = $row['ch_rate'];
echo '<div style="border:1px solid #EEE;font-size:12px">';
print "$tit_esp <br>";
print "Adultos : $adrate | Niños : $chrate ";
print "<a href='#?tourid=$tourID' class='myTour_$tourID' >ver detalles</a>";
print "</div>";
}
>
ここはjqueryのスクリプトです:?
<script>
$(function() {
$("#dialog:ui-dialog").dialog("destroy");
var adult = $("#adult"),
child = $("#chl"),
fecha = $("#datepicker"),
allFields = $([]).add(adult).add(child).add(fecha),
tips = $(".validateTips");
function updateTips(t) {
tips
.text(t)
.addClass("ui-state-highlight");
setTimeout(function() {
tips.removeClass("ui-state-highlight", 1500);
}, 500);
}
function checkLength(o, n, min, max) {
if (o.val()> max || o.val()< min) {
o.addClass("ui-state-error");
updateTips("El numero de " + n + " debes ser entre " +
min + " y " + max + ".");
return false;
} else {
return true;
}
}
function checkFecha() {
var dfecha = document.getElementById('datepicker').value;
if(dfecha == ""){
//dfecha.addClass("ui-state-error");
updateTips("Fecha Incorrecta");
return false;
}else{
return true;
}
}
function checkRegexp(o, regexp, n) {
if (!(regexp.test(o.val()))) {
o.addClass("ui-state-error");
updateTips(n);
return false;
} else {
return true;
}
}
$("#dialog-form").dialog({
position: 'center',
autoOpen: false,
draggable: true,
height: 300,
width: 410,
modal: true,
show : {
transitionIn: 'blind',
transitionOut: 'explode',
},
open: function(event, ui) {
$("#datepicker").datepicker('enable');
alert(regis)
$.ajax({
url: 'tour_cont.php',
data: "regis=" + regis + "",
dataType: 'json',
success: function(data){
var titulo = data[1];
var user = data[3];
var comenta = data[4];
$("#dialog-form").append("<tr>" +
"<td width='21%'>" + titulo + "</td>" + "</tr>");
}
});
},
buttons: {
"Agregar al Carrito": function() {
var bValid = true;
bValid = bValid && checkFecha(datepicker);
bValid = bValid && checkLength(adult, "adultos", 1, 10);
bValid = bValid && checkLength(child, "niños", 0, 10);
if (bValid) {
$("#users tbody").append("<tr>" +
"<td>" + adult.val() + "</td>" +
"<td>" + child.val() + "</td>" +
"<td>" + fecha.val() + "</td>" +
"</tr>");
$(this).dialog("close");
}
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
allFields.val("").removeClass("ui-state-error");
$('#datepicker').datepicker('disable');
}
});
$('a[class^=myTour]')
.button()
.click(function() {
$("#dialog-form").dialog("open");
});
$("#create-chichen")
.button()
.click(function() {
$("#dialog-form").dialog("open");
});
});
</script>
ホープ誰かが、私をunderstad高度でお願いします!!!
のようにjavascriptのにPHPの値を渡すことができます。 – Starx