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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:42:01+00:00 2026-05-20T14:42:01+00:00

I am a little lost at this point in my project. I work for

  • 0

I am a little lost at this point in my project. I work for a company that provides translation services. Well, I am making a simple calculator to calculate the cost of a translation based on the number of words in the entire project. It also changes rate based on the amount of words entered. I have that part done. I wrote this and it works:

function wordcountprice(){
var price,  final, 
    a=document.getElementById('words'),  
wc= parseFloat(a.value) || 0;
if(wc< 10000) price= .29;
else price= wc<20000? .26: .24; 
final= (wc*price).toFixed(2);
document.getElementById('estPrice').innerHTML = 'Your estimated price is: $' + final;}

At this point we have 6 types of translation work. Five of them would use that function and the last one would use a basic function with a fixed price. I was thinking I would use a drop down select box to change functions.

I am calling the above function in my HTML like this:

  <input type="text" id="words">&nbsp;&nbsp;<input type="button" id="button" value="Calculate" onClick="wordcountprice();"> <br /><b id='estPrice'>Estimated Price</b>

I have tried several things and none of them have worked. I assume that the best way to go about this is jQuery’s change() or select() function. I have tried making a new function with jQuery like this one:

$(function() {
$('#type').change(function() {
    var type = $(this).val();
    $('#button').val(type);
}); });

That only changes the value of the button and not the onClick event. I do not know how, or if, it is possible to change the onClick event like that. I don’t even know if that is the most efficient method to do what I want to do. I called that function when I was trying it with this HTML:

<select id='type'><option value='1'>A</option>
<option value='2'>B</option>
<option value='3'>C</option>
<option value='4'>D</option></select>

I am a noob with jQuery and haven’t been programming for a while so I am a little rusty.

Thanks for the help in advance.

  • 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-20T14:42:02+00:00Added an answer on May 20, 2026 at 2:42 pm

    I think you want to do something like this:

    $('#button').attr("onClick", "wordcountprice('"+type+"');" );
    

    http://api.jquery.com/attr/

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

Sidebar

Related Questions

I seem to be a little lost on what to so about this, im
I lost a little bit of time in this Python for statement: class MyListContainer:
I'm a little lost on this. I need to use two fractional bits 0.(a-1)(a-2)
I'm a little lost with the best way to process a record from a
I'm a little lost on moving a div within the dom. I basically need
I'm a little lost in general, but if someone could please briefly explain why
I'm a little bit lost here. In my nginx conf file I want a
A little knowledge can be a dangerous thing. Now that I've had a run
A little help here to figure out what error to run this piece of
12.2N 109.2W Given this location, how would I find a point on a mkmapkit

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.