Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery function to operate multiple divs
    primarykey
    data
    text
    <p>I'm writing a booking system in PHP and MySQL and the way that a user books a specific time slot is by clicking the Div which operates a JQuery function as you can see below:</p> <pre><code>$(document).ready(function(){ $('.free').click(function(){ $(this).html("&lt;div class='title'&gt;&lt;img src='images/loader.gif' alt='image' width='30' /&gt;&lt;/div&gt;").load('book.php?desk_id=&lt;?php echo $desk_id;?&gt;&amp;booking_id='+this.id); }); $('#bookweek').click(function(){ $('.free').html("&lt;div class='title'&gt;&lt;img src='images/loader.gif' alt='image' width='30' /&gt;&lt;/div&gt;").load('book.php?desk_id=&lt;?php echo $desk_id;?&gt;&amp;booking_id='+this.id); }); }) </code></pre> <p>What I am trying to do is get the second half of it where it would book the entire week to work. It partially works but doing a bit of investigation shows that it is not passing on the Div's ID in the URL, so obviously it's not passing on the correct variables to book.php which is making it not work.</p> <p>There are many Divs with class 'free' but each has its own seperate ID. Any help on how to pass the individual IDs on in a URL would be greatly appreciated,</p> <p>Many many thanks,</p> <p>Steve</p> <p>Edit:</p> <p>The calender is generated using the following code:</p> <pre><code>&lt;div id="bookweek" style="cursor:pointer"&gt;&lt;h1&gt;Book Entire Week&lt;/h1&gt;&lt;/div&gt; &lt;div class="block"&gt; &lt;div class="title"&gt;Times&lt;/div&gt; &lt;?php $days = 0; while($days &lt; 7) { $day = mktime(0, 0, 0, date("m"), date("d") + $days, date("Y")); $days++; echo '&lt;div class="title"&gt;'.date("D d/m/y", $day).'&lt;/div&gt; '; } ?&gt; &lt;/div&gt; &lt;?php $hours = 0; $counter = 0; while($hours &lt; count($bookingTimes)) { $name = $bookingTimes[$hours]; $hours++; echo '&lt;div class="block"&gt; &lt;div class="title"&gt;'.$name.'&lt;/div&gt; '; $i=0; $counter++; $days = 0; while($i &lt; 7) { $day = mktime(0, 0, 0, date("m"), date("d") + $days, date("Y")); $days++; $i++; $id = $counter + $day; echo '&lt;div class="free" id="'.$id.'"&gt;'.checkBooked($id,$desk_id).'&lt;/div&gt; '; } echo '&lt;/div&gt;'; } ?&gt; &lt;/div&gt; </code></pre>
    singulars
    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