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

  • SEARCH
  • Home
  • 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 6556681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:58:33+00:00 2026-05-25T12:58:33+00:00

I have 3 input fields <input type=text name=cust1 id=cust1 size=10 value= class=inputbox /> <input

  • 0

I have 3 input fields

<input type="text" name="cust1" id="cust1" size="10" value="" class="inputbox" />
<input type="text" name="cust2" id="cust2" size="10" value="" class="inputbox" />
<input type="text" name="rent_price" id="rent_price" size="10" value="" disabled="disabled" class="inputbox" />

jQuery Datepicker

$( "input#cust1" ).datepicker();
$( "input#cust2" ).datepicker();

And function to change value of input#rent_price:

    function setSum()
    {
        var hrs = countHrs();
        $("input#rent_price").attr('value',function(){
           sum = parseInt(BAG_PRICE)*parseInt(hrs);
           if (isNaN(sum))
           {
             sum = '';
             return sum;
           } 
           else 
           {
             return sum;
           }
        });
    }

so when i’m writind this:

    $( "input#cust1" ).change(setSum());
    $( "input#cust2" ).change(setSum());

value of input#rent_price changing only afted refreshing page. If i write alert in setSum() it triggers 2 times. So i need some advice.

  • 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-05-25T12:58:34+00:00Added an answer on May 25, 2026 at 12:58 pm

    use the datepicker’s onClose event:

    $( "input#cust1" ).datepicker({onClose:function(){ setSum() }});
    $( "input#cust2" ).datepicker({onClose:function(){ setSum() }});
    

    also when writing code, try not to repeat yourself, editted your function a bit:

    function setSum()
    {
        var sum = parseInt(BAG_PRICE)*parseInt(countHrs());
        if (isNaN(sum)) { sum = '' }
        $("input#rent_price").val(sum);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for email validation I have these two input fields: <input class=inputbox type=text name=data[subscriber][email] id=field_email
I have a form where users can add input fields with jQuery. <input type="text"
I have the following button: <input type=button count='<?php echo count($_SESSION['children']);?>' name=children class=add_child value=Add Another
I have a form with some fields of type text and 2 fields (name
I’m using jQuery Validate for my site’s contact form. The input fields have pre-populated
I have a hidden field <input type = 'hidden' name = test1 id =
I have 2 text fields. One is for the input of a member's id,
I have a form written below: <table> <tr> <td>Worker Type:</td> <td><input type=text id=WorkerTypeTB/></td> </tr>
I have an input field on my page where the user will type in
I have input fields, which I process with AJAX and send it on another

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.