Note that there are some explanatory texts on larger screens.

plurals
  1. POOne function that can book several different flights?
    primarykey
    data
    text
    <p>I have the following js fiddle:</p> <p>EDIT: <a href="http://jsfiddle.net/Godin1/z8zD5/6/" rel="nofollow">http://jsfiddle.net/Godin1/z8zD5/6/</a></p> <pre><code>HTML: &lt;table align="center" class="table table-bordered" style="border-radius: 15px;"&gt; &lt;col width="350"&gt; &lt;col width="600"&gt; &lt;col width="150"&gt; &lt;tr&gt; &lt;th&gt;Destination&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Villa Jibacoa &lt;br&gt; &lt;/td&gt; &lt;td&gt; &lt;ul&gt; &lt;li&gt;255 rooms&lt;/li&gt; &lt;li&gt;One 9-storey building&lt;/li&gt; &lt;li&gt;4 restaurants&lt;/li&gt; &lt;li&gt;5 bars&lt;/li&gt; &lt;li&gt;Pool&lt;/li&gt; &lt;li&gt;110 and 220 volts (adaptor required)&lt;/li&gt; &lt;/ul&gt; &lt;/td&gt; &lt;td&gt;$784 &lt;div style="position: relative; margin-top: 40px;"&gt; &lt;button id="first" type="button" onclick="SeatAssignment()" class="btn btn-success"&gt;Book Now!&lt;/button&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Gran Caribe Puntarena &lt;br&gt; &lt;/td&gt; &lt;td&gt; &lt;ul&gt; &lt;li&gt;110 rooms&lt;/li&gt; &lt;li&gt;Bungalow-style villas&lt;/li&gt; &lt;li&gt;2 restaurants&lt;/li&gt; &lt;li&gt;2 bars&lt;/li&gt; &lt;li&gt;Pools&lt;/li&gt; &lt;li&gt;220 volts (adaptor required)&lt;/li&gt; &lt;/ul&gt; &lt;/td&gt; &lt;td&gt;$947 &lt;div style="position: relative; margin-top: 40px;"&gt; &lt;button type="button" onclick="SeatAssignment()" class="btn btn-success"&gt;Book Now!&lt;/button&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Javascript: </p> <pre><code>var SeatSection; var seats = (11); var firstClass = 1; var economy = 6; var seatselection; seats = 0; function SeatAssignment() { seatselection = window.prompt("Please select 1 for firstclass and 2 for economy"); if (seatselection == 1 &amp;&amp; firstClass &lt;=5 &amp;&amp; seats == 0) { window.alert("You have been assigned first class seat #" + firstClass); seats[firstClass] = 1; ++ firstClass; } else if (seatselection == 2 &amp;&amp; economy &lt;=10 &amp;&amp; seats == 0) { window.alert("You have been assigned economy class seat #" + economy); seats[economy] = 1; ++ economy; } else { window.alert("Seats are full"); } } </code></pre> <p>I'm not sure why the "Book Now" option isn't working at the moment but basically a window pops up and you enter 1 or 2 for first class or economy seating. There will be multiple destinations to go to therefore I need a "Book Now" for every place. However, at the moment all of the buttons are going through the same function and therefore the seating is not exclusive from one plane to another. I am wondering if I have to create a different function to take care of the seating of every different flight or can I somewhere do this with only one function?</p> <p>Thanks</p>
    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