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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:56:29+00:00 2026-06-11T04:56:29+00:00

I have been developing a script that when a user types in correctly entered

  • 0

I have been developing a script that when a user types in correctly entered text the images will change the letter, letting the user know they entered it in correctly.

Preview here: Example word is “ate”.
http://jsfiddle.net/wjx6b/2/

I made sure it was set to check the index by using

$.each(text, function(index, item)

My problem is when I try setting it to a foreign word like “taberu” which is Japanese, I have to have two letters in each of the var text boxes like this

var text = ['ta', 'be', 'ru'];

but when I set it to that nothing happens when I start to type. Thanks to anyone who can help!

  • 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-11T04:56:31+00:00Added an answer on June 11, 2026 at 4:56 am

    The values in the ‘typed’ array are accessed one by one, while in the text array you put the characters in pairs as one value. So you’re comparing one character to a two character string in that case (comparing ‘ta’ to ‘t’, ‘be’ to ‘a’, ‘ru’ to ‘b’. Which will never be equal of course).

    To account for that you have to take the ‘stepsize’ into account (that is, in how many characters the images are grouped). Using substring you can then compare typed text blocks of size ‘stepsize’ to the values from the text array.

    working fiddle (you have to type aattee instead of ate now)

    another fiddle, here you have to type ‘taberu’

    in this fiddle stepsize is based on the first item of the text array

    this fiddle dynamically detects the stepsize in case the values in the text array do not have the same length (thanks to haynar for the suggestion)

    Update: this is the code of the last example (thanks Bob):

    var text = ['ta', 'ber', 'u'];
    
    var happy = ['http://www.vendian.org/howbig/UnstableURLs/letter_a_poster.png',
             'http://chineseknotting.org/projects/knotty/T-carrick.jpg',
             'http://etc.usf.edu/presentations/extras/letters/varsity_letters/38/17/E-400.png'
            ];
    
    var grumpy = $('img').map(function(){ return this.src; }).get(); //gets the original images from the HTML
    
    $("#test").on('keyup', function() {
        var typed = this.value;
        var textOffset = 0;
        $.each(text, function(index, item) {
            var stepsize = text[index].length;
            if (typed.substring(textOffset, textOffset+stepsize) == text[index]) {
                $('li', 'ul').eq(index).find('img').attr('src', happy[index]);
            }else{
                $('li', 'ul').eq(index).find('img').attr('src', grumpy[index]);
            }
    
            textOffset += stepsize;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a script on my linux box for quite some time,
I have been developing an user interface with Java Swing, and I have met
I have been developing the application, and I need that drawingg is executed in
I have been developing an application that uses Models that are based on a
I've been developing a image manipulation script which has a background and user can
I have been developing a program that needs to be run daily bases. I
I have been developing the application for drawing, and I have the problem: my
I have been developing an app for weeks on a desktop computer. I have
I have been developing in Android for approximately two months now. Yesterday, my eclipse
I have been developing the application for drawing and I need to detect double

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.