Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:37:22+00:00 2026-06-11T15:37:22+00:00

what i’m aiming is to show the other div when it selects one of

  • 0

what i’m aiming is to show the other div when it selects one of the two options
Full time and Part Time

and if possible compute a different value for each
When the user selects Part time
the value of PrcA will change to PrcB

this is the code i used

<!====================================================================================>


<script language="javascript">
<!--//

function dm(amount) 
{
  string = "" + amount;
  dec = string.length - string.indexOf('.');
  if (string.indexOf('.') == -1)
  return string + '.00';
  if (dec == 1)
  return string + '00';
  if (dec == 2)
  return string + '0';
  if (dec > 3)
  return string.substring(0,string.length-dec+3);
  return string;
}



function calculate()
{

  QtyA = 0;  
  TotA = 0;  

  PrcA = 1280; 
  PrcB = 640; 


  if (document.form1.qtyA.value > "")
     { QtyA = document.form1.qtyA.value };
  document.form1.qtyA.value = eval(QtyA);  



  TotA = QtyA * PrcA;
  document.form1.totalA.value = dm(eval(TotA));


  Totamt = 

     eval(TotA) ;

  document.form1.GrandTotal.value = dm(eval(Totamt));


} 


//-->
</script>


<!====================================================================================>
<p>
<label for="acct" style="margin-right:90px;"><strong>Account Type<strong><font color=red size=3> * </font></strong></label>
<select name="acct" style="background-color:white;" class="validate[custom[serv]] select-input" id="acct" value="">


                <option value="Full Time">Full-Time</option>
                <option value="Part Time">Part-Time</option>
                <option selected="selected" value=""></option>

</select></p>

<!====================================================================================>
<script>
$(document).ready(function() {
    $("input[name$='acct']").select(function() {
        var test = $(this).val();

        $("div.desc").hide();
        $("#acct" + test).show();
    });
});
</script>


<!====================================================================================>
<p>
<table><tr><td>
<lable style="margin-right:91px;"># of Agent(s)<font color=red size=3> * </font></lable>
</td><td>
<input style="width:25px; margin-left:5px;" type="text" class="validate[custom[agnt]] text-input" name="qtyA" id="qtyA" onchange="calculate()" />
</td><td>
<div id="acctFull Time" class="desc">
 x 1280 = 
</div>
<div id="acctPart Time" class="desc" style="display:none">
 x 640 = 
</div>
</td><td>
$<input style="width:80px; margin-left:5px;" type="text" readonly="readonly"  name="totalA" id="totalA" onchange="calculate()" />
</p>
</td></tr></table>

is there any way for me to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:37:23+00:00Added an answer on June 11, 2026 at 3:37 pm

    Check this [FIDDLE] ..

    Added two classes to the div’s which show the amount.. This should make like easier to access them..

        $(document).ready(function() {
        $("#acct").on('change', function() {
            var selVal = $(this).val();
            if (selVal == '1') { // Full Time
                $('.parttime').hide();
                $('.fulltime').show();
                $('.agent').show();
                $('.error').hide();
            }
            else if (selVal == '2') { // 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 == '1') {
                    total = parseInt($(this).val()) * 1280;
                }
                else if (selVal == '2') {
                    total = parseInt($(this).val()) * 640;
                }
                $('#totalA').val(total.toFixed(2));
            }
            else {
                $(this).val('0');
                 $('#totalA').val('0.00');
            }
        });
    });​
    

    Also you can completely eliminate the vanilla javascript and go with jQuery that should be lot easier..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tracked down a weird MySQL problem to the two different ways I was
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.