New to Javascript and trying to solve a problem

Discussion in 'Javascript' started by Guy Noir, Oct 23, 2006.

  1. Guy Noir

    Guy Noir Guest

    Hello all. I am new to Javascript but versed in JAva, c#, etc.

    I'm running into a problem and I'm hoping someone can point me in the
    right direction.

    I have 2 images (Up and down arrows) and I'm trying to change the value
    of a text box based on if the up or down arrow was pressed. (Spinner
    box).

    I am getting an error and I'm not quite sure how to go about debugging.
    (Can someone suggest aan easy to use debugger?)

    The error is: Error: getDOMObject is not defined. I assume the problem
    is with one of these 2 lines, and I suspect it's the "State" line:

    var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
    var ob___UpDownControl1_State=
    getDOMObject("__UpDownControl1_State");

    Here are the HTML form attributes:

    <input type="text" id="__UpDownControl1_Input"
    name="__UpDownControl1_Input" height="30px" value="2" />

    <img title="Increment value" src="images/UpArrow_10x10.gif"
    onclick="javascript:eek:nUpArrowClick_UpDownControl1();"
    style="border-width:0;" />

    <img title="Decrement value" src="images/DownArrow_10x10.gif"
    onclick="javascript:eek:nDownArrowClick_UpDownControl1();"
    style="border-width:0;" />

    And here is the associated javascript:

    <script language="javascript">
    var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
    var ob___UpDownControl1_State=
    getDOMObject("__UpDownControl1_State");
    var UpDownControl1_MaxVal = 10;
    var UpDownControl1_MinVal = 0;
    var UpDownControl1_IncVal = 1;
    var iobUpDownControl1Val=obUpDownControl1.value;
    function onUpArrowClick_UpDownControl1()
    {
    if (((iobUpDownControl1Val-0) + (UpDownControl1_IncVal+0))<=
    UpDownControl1_MaxVal)
    {
    obUpDownControl1.value =(iobUpDownControl1Val-0) +
    (UpDownControl1_IncVal+0);
    iobUpDownControl1Val=obUpDownControl1.value;
    ob___UpDownControl1_State.value = obUpDownControl1.value;
    }
    }

    function onDownArrowClick_UpDownControl1()
    {
    if (((iobUpDownControl1Val-0)-(UpDownControl1_IncVal-0))>=
    UpDownControl1_MinVal)
    {
    obUpDownControl1.value
    =(iobUpDownControl1Val-0)-(UpDownControl1_IncVal-0);
    ob___UpDownControl1_State.value = obUpDownControl1.value;
    iobUpDownControl1Val=obUpDownControl1.value;
    }
    }

    function getControlValue_UpDownControl1(strVal)
    {
    var iVal = __UpDownControl1_Input.value;
    return parseInt(iVal, 10);
    }
    </script>

    Any help or if you could point me in the right direction would be most
    excellent.

    TIA
    -Guy
    Guy Noir, Oct 23, 2006
    #1
    1. Advertising

  2. Guy Noir

    web.dev Guest

    Guy Noir wrote:
    > The error is: Error: getDOMObject is not defined. I assume the problem
    > is with one of these 2 lines, and I suspect it's the "State" line:
    >
    > var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
    > var ob___UpDownControl1_State=
    > getDOMObject("__UpDownControl1_State");
    >
    > Here are the HTML form attributes:
    >
    > <input type="text" id="__UpDownControl1_Input"
    > name="__UpDownControl1_Input" height="30px" value="2" />
    >
    > <img title="Increment value" src="images/UpArrow_10x10.gif"
    > onclick="javascript:eek:nUpArrowClick_UpDownControl1();"
    > style="border-width:0;" />
    >
    > <img title="Decrement value" src="images/DownArrow_10x10.gif"
    > onclick="javascript:eek:nDownArrowClick_UpDownControl1();"
    > style="border-width:0;" />


    The use of the javascript pseudo-protocol is unnecessary and may do
    more harm than good.

    >
    > <script language="javascript">


    The language attribute is deprecated. Use the type attribute instead:

    <script type = "text/javascript">

    > var obUpDownControl1= getDOMObject("__UpDownControl1_Input");


    The error message you have is actually pretty helpful. From the script
    that you have given, I do not see a method called getDOMObject()
    declared anywhere. Define this method and all should be well. Or
    perhaps you meant the getElementById() method instead?
    web.dev, Oct 23, 2006
    #2
    1. Advertising

  3. Guy Noir

    Guy Noir Guest

    web.dev wrote:
    > Guy Noir wrote:
    > > The error is: Error: getDOMObject is not defined. I assume the problem
    > > is with one of these 2 lines, and I suspect it's the "State" line:
    > >
    > > var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
    > > var ob___UpDownControl1_State=
    > > getDOMObject("__UpDownControl1_State");
    > >
    > > Here are the HTML form attributes:
    > >
    > > <input type="text" id="__UpDownControl1_Input"
    > > name="__UpDownControl1_Input" height="30px" value="2" />
    > >
    > > <img title="Increment value" src="images/UpArrow_10x10.gif"
    > > onclick="javascript:eek:nUpArrowClick_UpDownControl1();"
    > > style="border-width:0;" />
    > >
    > > <img title="Decrement value" src="images/DownArrow_10x10.gif"
    > > onclick="javascript:eek:nDownArrowClick_UpDownControl1();"
    > > style="border-width:0;" />

    >
    > The use of the javascript pseudo-protocol is unnecessary and may do
    > more harm than good.
    >
    > >
    > > <script language="javascript">

    >
    > The language attribute is deprecated. Use the type attribute instead:
    >
    > <script type = "text/javascript">


    Thanks for the tip.

    >
    > > var obUpDownControl1= getDOMObject("__UpDownControl1_Input");

    >
    > The error message you have is actually pretty helpful. From the script
    > that you have given, I do not see a method called getDOMObject()
    > declared anywhere. Define this method and all should be well. Or
    > perhaps you meant the getElementById() method instead?


    OK. I see what happened here. What is TRYING to be accomplished (And
    again this may be "the old way") is that we are trying to get and set
    the value of a text box on this form.

    I see now that document.getElementById() is working for me. Thanks so
    much for the feedback and I did learn something here!
    -Guy
    Guy Noir, Oct 24, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Yong
    Replies:
    2
    Views:
    404
    Roedy Green
    Oct 3, 2005
  2. bruce
    Replies:
    0
    Views:
    488
    bruce
    Jul 21, 2008
  3. bruce
    Replies:
    0
    Views:
    615
    bruce
    Jul 21, 2008
  4. Gorge Lucas

    problem I am trying to solve

    Gorge Lucas, May 4, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    365
    Alexey Smirnov
    May 4, 2009
  5. Replies:
    2
    Views:
    442
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page