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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:03:00+00:00 2026-05-23T23:03:00+00:00

I have a simple script works fine in html. Yet in a gsp, it

  • 0

I have a simple script works fine in html. Yet in a gsp, it doesn’t work anymore.

My script is very simple, as below:

// program variables
var displayElement;

// constants
var maxLength = 300;

// calculator variables
var text;
var currentLength;
var dotPosition;

var lastNumber;
var currentNumber;
var rememberedNumber;
var operator;

alert('hello22');

function parseNumber(number) {
        if ((number == -1) && (dotPosition > 0) || (maxLength == currentLength)) return;
        if (currentLength == 0) text = '';
        currentLength++;
        if (number == -1) {
                text += '.';
                dotPosition = currentLength;
        } else text += number;

        displayElement.value = text;
}

function parseBackspace() {
        if (currentLength == 0) return;
        if ('.' == text[currentLength-1]) dotPosition = 0;
        text = text.slice(0, currentLength-1);
        if(--currentLength == 0) text = '';
        displayElement.value = text;
}

function parseClearEntry() {
        currentLength = 0;
        text = '0';
        dotPosition = 0;
        displayElement.value = text;
}

function parseClear() {
        parseClearEntry();
        lastNumber = 0;
        operator = '';
        //added by Kevin
        displayElement.value = '';
}

function initAll() {
        alert('hello1113333333');
        text = '0';
        currentNumber = 0;
        currentLength = 0;
        displayElement = document.getElementById('TextBox');
        rememberedNumber = 0;
        lastNumber = 0;
        dotPosition = 0;
        alert('hello1111111111');
}

When I included into the gsp view page, I put <g:javascript src="getKey.js" /> between the <head></head>.

Then I call the function initAll() like <body onload="initAll()">, and others like <div class="holder"><input type="button" class="buttonstyle" value="7" name="Seven" onclick="parseNumber(7)" /></div>

Can anyone tell me what’s wrong? I am sure the script has been included correctly because the alert “hello22” was threw.

  • 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-23T23:03:00+00:00Added an answer on May 23, 2026 at 11:03 pm

    Try to put somewhere following code at the footer:

    <g:script>
    (function() { initAll(); })();
    </g:script>
    

    or

    <g:script>
    window.onload = initAll; //note that is's without braces
    </g:script>
    

    instead of <body onload="initAll"

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

Sidebar

Related Questions

I have a simple show/hide jquery script that works fine on its own, The
I have a simple Ajax script that works perfectly fine in Chrome, Internet Explorer
I have a simple load more style script that works fine on the index
I have a simple script which is used to start another program. This other
I have a very simple script that slides a message down from the top
I have a jQuery script, which is filtering an html select list. It works
I have a simple script that does some search and replace. This is basically
I have a simple Python script that I want to stop executing if a
I have a simple linux script: #!/bin/sh for i in `ls $1` do echo
I have a simple php script on a server that's using fsockopen to connect

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.