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 6968073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:24:15+00:00 2026-05-27T16:24:15+00:00

I have an input box whose id is sellingprice . i want to check

  • 0

I have an input box whose id is sellingprice. i want to check the input value in jquery using the if else condition and display the result value in an input box whose id is result.

example:

if the value in input box is greater 50 it will display in the other input box the word too high

i’m a newbie in jquery and confused on how to implement it. Appreciate if someone may guide me through this.

I’ll revised my question from above:

i have a table value something like this:

sellingprice      result

51                 ?
49                 ?

if the sellingprice value is greater than 50 this will be the calculation: sellingprice – 50 * 0.05 + 3.5

and if the sellingprice value is less than 50 the calculation will be: sellingprice * 0.07;

sorry i’m just trying to simplify my question but this is really the problem that i’m been facing as of this moment. Hope to guide me through 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-05-27T16:24:16+00:00Added an answer on May 27, 2026 at 4:24 pm

    [edit after your update]

    var sp = $('#sellingprice').val() | 0;
    if (sp <= 50) {
       $('#result').val(sp * 0.07)
    }
    else {
       $('#result').val(sp - 50 * 0.05 + 3.5) /* check the operations order */
    }
    

    where

    $('#sellingprice').val() | 0
    

    is an explicit (and more efficient than parseInt) int casting. If you can insert also floated point values change this statement with var sp = parseFloat($('#sellingprice').val())

    with a ternary operator the code is simply reduced to

    var sp = $('#sellingprice').val() | 0;
    $('#result').val((sp <= 50)? sp - 50 * 0.05 + 3.5  : sp * 0.07)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an input box whose value i want to clear if the user's
I'm new to jQuery and I want to have a input box from a
I have a select box created by jquery whose class is 'classTypex'. I want
I have an input box for which I am using the Jquery autocomplete function.
I have an input box that takes values from 0-100. I want to prevent
I have an input box which I want to handle two types of information,
I am want to have a input box, where a user can add or
I have a jQuery autocomplete input box for time. It lists all available times
I have a text box in a div whose display is none by default
I want to create a simple gsp page which will have an input box

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.