Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery and the use of variables and functions
    primarykey
    data
    text
    <p>I'm working on a jquery estimating program which is in a form tag. When I'm finished this will be a rather large script. On of many task, I have about 50 check boxes in a group which when checked it will advance a ui slider one step forward. If I uncheck the box it steps the slider back one.</p> <p>The boxes are all hidden until I click on a radio button which unhides the check boxes at the same time will read how many check boxes are check and return the number to the slider. </p> <p>I have a function which also adjust the total estimated price each time a box is checked or unchecked.</p> <p>Sense this is a form......I have a contact.php file which will extract all information from the form and emailed to the website owner.</p> <p>Now the Big Question is.......I have 50 Check boxes...</p> <p><strong>A sample of the HTML</strong></p> <pre><code> &lt;input type="checkbox" id="R_C-helpPage01" name="helpPage01" value="helpPage01" class="R_C R_C-width20" /&gt; &lt;label id="R_C-helpPage01" class="W_E"&gt;&lt;/label&gt; &lt;input type="checkbox" id="R_C-helpPage02" name="R_C-helpPage02" value="helpPage02" class="R_C R_C-width20" /&gt; &lt;label id="R_C-helpPage02" class="R_C"&gt;&lt;/label&gt; &lt;input type="checkbox" id="R_C-helpPage03" name="R_C-helpPage03" value="helpPage03" class="R_C R_C-width20" /&gt; &lt;label id="R_C-helpPage03" class="R_C"&gt;&lt;/label&gt; </code></pre> <p><strong>A Sample of some of the var</strong></p> <pre><code> var helpPage01 = 'Home Page'; var helpPage02 = 'About Us'; var helpPage03 = 'Our Services'; var helpPage04 = 'Contact Us'; </code></pre> <p>Hear is the main function I'm not sure of how to make all these check buttons use just this function without having to make 50 copys of the function for each check box.</p> <p>My first guess is something like this below</p> <pre><code> $('#And 47 more ID's, #helpPage03, #helpPage02, #helpPage01').click(function() and bla bla bla </code></pre> <p>Function as is now..</p> <pre><code> $helpPage.click(function () { if ($pages.val() == 20) { alert('Please call for a bulk estimate: ' + phoneNumber); return false; } if ($helpPage.is(':checked')) { var s = $pageSlider, val = s.slider("value"), step = s.slider("option", "step"); s.slider("value", val + step); $pages.val(("value", val + step)); $amount.val([("value", val + step) * pageAmount] / [$daySlider.slider("value")]); $slideCalc.click(); } else { var s = $pageSlider, val = s.slider("value"), step = s.slider("option", "step"); s.slider("value", val - step); $pages.val(("value", val - step)); $amount.val([[("value", val - step) * pageAmount] / $daySlider.slider("value")]]); $slideCalc.click(); } }); </code></pre> <p><strong>More</strong></p> <pre><code> $('#R_C-helpPage01').html(helpPage01 + '&lt;br /&gt;'); $('#R_C-helpPage02').html(helpPage02 + '&lt;br /&gt;'); $('#R_C-helpPage03').html(helpPage03 + '&lt;br /&gt;'); $('#R_C-helpPage04').html(helpPage04 + '&lt;br /&gt;'); </code></pre> <p>If you need more info to make a reasonable stab at it, let me know.</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.
    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