Note that there are some explanatory texts on larger screens.

plurals
  1. POClear Input textbox fields after select box selected index has changed
    primarykey
    data
    text
    <p>I am trying to clear the current values of <code>Input</code> fields <code>totalA</code> and <code>qtyA</code> when the selected value of a <code>select</code> box, <code>acct</code> has been changed.</p> <p>I have this code so far, but am unsure where to clear the values.</p> <pre><code>&lt;script language="javascript"&gt; $(document).ready(function() { $("#acct").on('change', function() { var selVal = $(this).val(); if (selVal == 'Full-Time') { // Full Time $('.parttime').hide(); $('.fulltime').show(); $('.agent').show(); $('.error').hide(); } else if (selVal == 'Part-Time') { // Part Time $('.parttime').show(); $('.fulltime').hide(); $('.agent').show(); $('.error').hide(); } else { $('.parttime').hide(); $('.fulltime').hide(); $('.agent').hide(); $('.error').show(); } }); $('#qtyA').on('change', function() { var selVal = $("#acct").val(); if (!isNaN($(this).val())) { var total = 0; if (selVal == 'Full-Time') { total = parseInt($(this).val()) * 1280; } else if (selVal == 'Part-Time') { total = parseInt($(this).val()) * 720; } $('#totalA').val(total.toFixed(2)); } else { $(this).val('0'); $('#totalA').val('0.00'); } }); }); &lt;/script&gt; </code></pre> <p>The <code>select</code> box code:</p> <pre><code>&lt;p&gt; &lt;label for="acct" style="margin-right:45px;"&gt;&lt;strong /&gt;Account Type&lt;strong&gt;&lt;font color="red" size="3"&gt; * &lt;/font&gt;&lt;/strong&gt;&lt;/label&gt; &lt;select name="acct" style="background-color:white;" id="acct" value="" class="validate[custom[cname]] text-input"&gt; &lt;option value="Full-Time"&gt;Full-Time&lt;/option&gt; &lt;option value="Part-Time"&gt;Part-Time&lt;/option&gt; &lt;option selected="selected" value=""&gt;&lt;/option&gt; &lt;/select&gt; &lt;/p&gt; </code></pre> <p>The <code>Input</code> fields:</p> <pre><code>&lt;p&gt; &lt;table class="agent"&gt; &lt;tr&gt; &lt;td&gt; &lt;lable style="margin-right:89px;"&gt;# of Agent(s)&lt;font color="red" size="3"&gt; * &lt;/font&gt;&lt;/lable&gt; &lt;/td&gt; &lt;td&gt; &lt;input style="width:25px; margin-left:5px;" type="text" name="qtyA" id="qtyA" /&gt; &lt;/td&gt; &lt;td&gt; X &amp;nbsp; $&lt;label id="acctFull Time" class="desc fulltime" style="display:none"&gt;1280&lt;/label&gt; &lt;label id="acctPart Time" class="desc parttime" style="display:none"&gt;720&lt;/label&gt; = &amp;nbsp; &lt;/td&gt; &lt;td&gt; $&lt;input style="width:65px; margin-left:5px;" type="text" readonly="readonly" name="totalA" id="totalA" onchange="calculate()" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/p&gt; &lt;p class="error" align="center"&gt;Please select an Account Type.&lt;/p&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.
    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