Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're on the right track, it's best to build the options in your HotelQuery function. Here we're using a self-terminating while (optimized 'for' statement), and using an array join it's faster and perhaps cleaner than string concatenation. Let me know if you have any questions. All the best, M</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; $(function(){ function buildPriceOptions(rate,type) { var i = rate.length, a = []; while(i--) a.push( [ '&lt;option value="',rate[i],'"&gt;',type[i], ' (',rate[i],')','&lt;/option&gt;' ] .join('') ); return a.reverse().join('\n') } function HotelQuery() { switch (true) { case true : var strHotelName = 'Jamstone Inn'; var strHotelDesc = 'Hotel Description Jamstone Inn'; var strHotelRate = [ '980.00', '1,300.00', '1,600.00', '1,500.00', '1,800.00', '300.00', '150.00', '200.00']; var strHotelRoomType = [ 'Single Room', 'Delux Room','Twin Room', 'Matrimonial Room', 'Presidential Suites', 'Extra Bed', 'Free Breakfast', 'Extra Person']; var htmPrice = buildPriceOptions( strHotelRate, strHotelRoomType ); break; } return { name : strHotelName, desc : strHotelDesc, rate : strHotelRate, roomType : strHotelRoomType, prices : htmPrice }; }; hotel = HotelQuery(); $('#HasCart_TetrisHotel .hotMenu').append( [ '&lt;select name="price"&gt;', hotel.prices, '&lt;/select&gt;' ] .join('') ); }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="HasCart_TetrisHotel"&gt; &lt;div class="hotMenu"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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