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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:13:58+00:00 2026-05-31T07:13:58+00:00

Ive got a document and when the user enters something into one input I

  • 0

Ive got a document and when the user enters something into one input I need to show a response in a second input box. I can get the user given value, i can process it, but when I try to set the second input box with the result I get the error $.field is null. Here is the code:

$('places').addEvent('keyup', function(){
    var places = $('places').value;
    alert("PLACE: "+places);
    var price = values[places];
    var nights = $('nights').value.toInt();
    alert("NIGHTS: "+nights);
    var total = price * nights;
    alert("TOTAL: "+total);
    $('pricepernight').set('text', total);
    $('pricetotal').set('text', total - ((total / 100) * 21));
});

So I get the place value. I pull the price of the place out of an assoc array. I then multiple that price by the amount of nights field in by the user and this is then my total amount. It is this amount that I cannot set to. Note that the alert shows the correct amount.

and the html looks like this

<div class='block'>
    <input type="text" id="places" />
</div>

<div class='block'>
    <label for="nachten">Aantal nachten</label>
    <input type="text" id="nights" />
</div>

<div class='block long'>
    <span class='label'>Prijs per slaapplaats per nacht</span>
    <input type="text" class='resultfield' id='pricepernight' />
</div>
<div class='block last'>
    <span class='label'>Totaalprijs excl. btw</span>
<input type="text" class='resultfield' id='pricetotal'/>
</div>

Firebug responds:

String contains an invalid character
[Break On This Error]   

...x:\'4W\',3X:18.1l,al:18.1l,1Q:18.1l,as:18.1l,8S:18.1l,1F:O,3E:{x:\'1u\',y:\'1o\'...

Any ideas/suggestions anyone? Thank you 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-31T07:13:59+00:00Added an answer on May 31, 2026 at 7:13 am

    right. you seem to have used a mix of mootools and jquery code.

    $('nights').addEvent('keyup', function(){
        var places = $('places').value;
        var price = values[places];
        var nights = $('nights').value;
        var total = price * nights;
        alert(total);
        $('#pricepernight').val(total);
        //$('#pricetotal').val(total - ((total / 100) * 21));
    }); 
    

    in mootools 1.2+, this should be:

    $('nights').addEvent('keyup', function(){
        var places = $('places').get('value');
        var price = values[places];
        var nights = $('nights').get('value');
        var total = price * nights;
        alert(total);
        $('pricepernight').set('value', total);
        //$('#pricetotal').val(total - ((total / 100) * 21));
    }); 
    

    there’s an implied global array values. also, this is not very safe as nights may not be integer.

    the point is. #id -> id and .val() -> set('value', 'newvalue') – or .get('value')

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

Sidebar

Related Questions

I've got a fairly complex XML document, where I need to remove specific nodes
Ive got a problem. In each document I've got fields: threads.id and posts.id. I
I've got a script that takes a user uploaded RTF document and merges in
I've got a Qt program where a user can select the location by Google
I've got a document like this: <p class=top>I don't want this</p> <p>I want this</p>
I've got an XML document that is in either a pre or post FO
I've got an ASP document that 5 years old. Actually I'm working with PHP
I've got this script on my website : $(document).ready(function() { function filterPath(string) { return
I've got a script executing on $(document).ready() that's supposed to vertically align block element
I've got an XPathNavigator at the root of a document. Several levels down, there's

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.