/    Sign up×
Community /Pin to ProfileBookmark

how to get value of the name of the tag?

Hi, how can i get / set value of the name property of any tag?

Like here is what im trying to do:

[code=php]
<script language=javascript>

function test(e){
//alert(e.id)
next.name=”Is_it_working;
}

function next(e){
alert(e.my_tag);
}
</script>

<img id=”hello.jpg” onclick=test(this)>
<span id=”next” name=”” onclick=next(this) >Hello</span>

[/code]

  • 1. you click on image, rhis assigns the value to the name of the SPAN… then when you click on span you get the valuee assigned by clicking on the image
  • to post a comment
    JavaScript

    10 Comments(s)

    Copy linkTweet thisAlerts:
    @jabezJun 30.2006 — You could try downloading Firefox browser, and install the Firebug javascript debugger. It is very neat, and you can then use the console in the debugger to check out your javascript code.
    Copy linkTweet thisAlerts:
    @alexusauthorJun 30.2006 — jabez! what are you talking about? I'm asking HOW can I assign the value!

    i Want to use tag propery as a temporary variable to store curent image name so i would be able to go to the next image based on curent image name.
    Copy linkTweet thisAlerts:
    @EricWJun 30.2006 — <script language=javascript>

    function test(e){

    document.getElementById('next').my_tag="Is_it_working";

    }

    function next(e){

    alert(e.my_tag);

    }

    </script>


    <img id="hello.jpg" onclick=test(this)>&nbsp;&nbsp;

    <span id="next" my_tag="marvin" onclick=next(this) >Hello</span> ?
    Copy linkTweet thisAlerts:
    @alexusauthorJun 30.2006 — yey thanks!

    one more problem is fixed ? one more to go ?
    Copy linkTweet thisAlerts:
    @felgallJul 01.2006 — There is no such attribute as my_tag in a span tag so that code is invalid and wont display proerly in most browsers. You can't just invent your own HTML attributes - you have to use what is already there. If you want to invent tags you need to use XML instead and that means that you can't support Internet Explorer.
    Copy linkTweet thisAlerts:
    @alexusauthorJul 01.2006 — but it seams to be working, altough i van use name property instead of my_tag
    Copy linkTweet thisAlerts:
    @VladdyJul 01.2006 — There is no such attribute as my_tag in a span tag so that code is invalid and wont display proerly in most browsers. You can't just invent your own HTML attributes - you have to use what is already there. If you want to invent tags you need to use XML instead and that means that you can't support Internet Explorer.[/QUOTE]

    Custom attributes only invalidate HTML code. They have no adverse effect on how the document is displayed. Also the two most popular browsers (IE and Gecko) parse custom attributes into the document tree, regardless of DTD (and I have no reason to expect such behaviour to change in the future, as it would only add programming and processing overhead). Therefore there is no harm in using custom attributes which are great for configuring (or passing data to) script components.

    Of course, the proper way of doing it would be serving the file as XHTML with custom DTD, but it makes IE choke (as you mentioned).
    Copy linkTweet thisAlerts:
    @CharlesJul 01.2006 — Of course, the proper way of doing it would be serving the file as XHTML with custom DTD, but it makes IE choke (as you mentioned).[/QUOTE]IE handles XML just fine and better than FF. You just need to tell it how to transform the XML into HTML.
    Copy linkTweet thisAlerts:
    @VladdyJul 01.2006 — IE handles XML just fine and better than FF. You just need to tell it how to transform the XML into HTML.[/QUOTE]
    I was referring to the fact that IE goes into quirks mode whenever <!DOCTYPE... is not found on the first line and it is not explicitely set to Strict...
    Copy linkTweet thisAlerts:
    @alexusauthorJul 01.2006 — well i got that temp variable,

    how about how can I make this, if finction is called the 'i' is increased by 1 aka i++

    I tried this

    var i=0;

    function test(){

    alert(i);

    i=i+1;

    }

    but this doesnt work :-(
    ×

    Success!

    Help @alexus 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 5.18,
    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: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

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

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...