/    Sign up×
Community /Pin to ProfileBookmark

Object Name Confusion – Script No work.

I can’t seem to find the answer in my JavaScript books other than I need to specify the object name to get the output… but I don’t know:

[list=1]

  • [*]

    what the default name is


  • [*]

    how to specify the object name


  • [*]

    how to determine what the current object name is using tools


  • [/list]

    So, if someone could enlighten me, that would be a great post-christmas gift.

    Here is my very simple script:

    — begin —
    [COLOR=Blue]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
    <html>
    <head>
    <title> My Attitude</title>
    </head>
    <script type=”text/javascript” language=”javascript1.2″><!–
    function attitudeReturn( ) {

    alert( ‘I am trying… ‘ );
    window.myAttitude.value= ‘Steve is happy.’;

    }
    //–></script
    <body>
    <form method=”post” action=”” name=”document”>
    <input type=”text” name=”myAttitude” onclick=”return false;” onmouseup=”attitudeReturn();return false;” >
    </form>
    </body>
    </html>[/COLOR]
    — end —

    to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @vwphillipsDec 26.2005 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> My Attitude</title>
    </head>
    <script type="text/javascript" language="javascript1.2"><!--
    function attitudeReturn(obj) {

    alert( 'I am trying... '+obj.name );
    }
    //-->
    </script
    <body>
    <form method="post" action="" name="document">
    <input type="text" name="myAttitude" onclick="return false;" onmouseup="attitudeReturn(this);return false;" >
    </form>
    </body>
    </html>[/CODE]
    Copy linkTweet thisAlerts:
    @dacturaauthorDec 26.2005 — This does give me the object name. Thanks! However, the second part of the function is to copy the string [COLOR=Blue]'Steve is happy.'[/COLOR] to the text box.

    The alert works okay... and I'm sorta comforted that I know the object name, but setting the value of that object is what I really want to do. (Maybe I'm not asking the right question... I don't know.)

    Here's what the updated code (that doesn't quite work) looks like now.

    [COLOR=Blue]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>

    <head>

    <title> My Attitude</title>

    </head>

    <script type="text/javascript" language="javascript1.2"><!--



    function attitudeReturn(obj ) {

    alert( 'I am trying... '+obj.name );

    obj.name.value= 'Steve is happy.';

    }

    //--></script>

    <body>

    <form method="post" action="" name="document">

    <input type="text" name="myAttitude" onclick="return false;" onmouseup="attitudeReturn(this);return false;" >

    </form>

    </body>

    </html>[/COLOR]


    What the form is suppose to do is 1. present the alert (this works) 2. after typing something into the field, replace it with 'Steve is happy." (does not work.)

    I think it's because I don't know how to specify the object name correctly.
    Copy linkTweet thisAlerts:
    @vwphillipsDec 26.2005 — obj.value='whatever tou want';
    Copy linkTweet thisAlerts:
    @dacturaauthorDec 27.2005 — Thanks! I think I make things too hard.
    ×

    Success!

    Help @dactura spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...