I've just started with php and js (jquery) and need help. I'm trying to do smth like betting service.
1. On html page user choose racecoast, using jquery I send its ID to php file, and it loads timetable:
like this:
while($row = mysqli_fetch_array($result)) { if ($row['date_time'] > date("Y-m-d h:i:sa")){
echo "<tr>";
echo "<td colspan='6' class='race' style = 'font-size: 14pt;' id = '".$row['raceID']."' >" . $row['raceID'] . "</td>";
it works. 2. Then, in the same php file I use
echo "<script type='text/javascript'>
$(document).ready(function(){
$('.race').click(function() {
var elid = $(this).attr('id');
and js perfectly gets the ID of racecoast. But I can't send elid value back to php.
I've tried to use simple $_[GET], sessions, cookies, to set value on some attrib in my html and then get it, created one more php file, to send information there by load(...) function. Maybe, I did something wrong?..
I feel that my script should be in php file, but how to be then?
my last try, and more code:
while($row = mysqli_fetch_array($result)) { // if ($row['date_time'] > date("Y-m-d h:i:sa")){
echo "<tr>";
echo "<td colspan='6' class='race' style = 'font-size: 14pt;' id = '".$row['raceID']."' >" . $row['raceID'] . "</td>";
echo "<td colspan='6' class='race' style = 'font-size: 14pt;'id = '".$row['raceID']."'>" . $row['date_time'] . "</td>";
echo "<td colspan='6' class='race' style = 'font-size: 14pt;'id = '".$row['raceID']."'>" . $row['special_title'] . "</td>";
echo "</tr>";//} }
echo "</tbody>
</table>";
echo "
<script type='text/javascript'>
$(document).ready(function(){
$('.race').click(function() {
var nid = $(this).attr('id')
alert(nid);
document.cookie = 'newid=' + nid;
});});
</script>";
$choise = $_COOKIE["newid"];
echo $choise;