Note that there are some explanatory texts on larger screens.

plurals
  1. POpassing value from php to jquery
    primarykey
    data
    text
    <p>I need some help, I want to know how can I pass a value, from a PHP variable to jquery script? What I'm doing is openning a modal window, from a list of elements created from a mysql browse, so I need to pass trhough the anchor a variable value. Here is my code :</p> <pre><code>&lt;?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 '&lt;div style="border:1px solid #EEE;font-size:12px"&gt;'; print "$tit_esp &lt;br&gt;"; print "Adultos : $adrate | Ni&amp;ntilde;os : $chrate "; print "&lt;a href='#?tourid=$tourID' class='myTour_$tourID' &gt;ver detalles&lt;/a&gt;"; print "&lt;/div&gt;"; } </code></pre> <p>?></p> <p>here is jquery script:</p> <pre><code>&lt;script&gt; $(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()&gt; max || o.val()&lt; 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( "&lt;tr&gt;" + "&lt;td width='21%'&gt;" + titulo + "&lt;/td&gt;" + "&lt;/tr&gt;" ); } }); }, buttons: { "Agregar al Carrito": function() { var bValid = true; bValid = bValid &amp;&amp; checkFecha( datepicker ); bValid = bValid &amp;&amp; checkLength( adult, "adultos", 1, 10 ); bValid = bValid &amp;&amp; checkLength( child, "niños", 0, 10 ); if ( bValid ) { $( "#users tbody" ).append( "&lt;tr&gt;" + "&lt;td&gt;" + adult.val() + "&lt;/td&gt;" + "&lt;td&gt;" + child.val() + "&lt;/td&gt;" + "&lt;td&gt;" + fecha.val() + "&lt;/td&gt;" + "&lt;/tr&gt;" ); $( 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" ); }); }); &lt;/script&gt; </code></pre> <p>Hope somebody understad me, thank you in advanced !!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload