Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    79
    Thanks
    2
    Thanked 1 Time in 1 Post

    codiga button reference in javascript

    A button in form like this

    Code:
    <form name="WHO">
            <div data-role="fieldcontain">
              <fieldset data-role="controlgroup" data-type="horizontal">
                <legend></legend>
                <input type="radio" name="ACTION" id="ACTION_0" value="1" accesskey="1"  onclick="jazda()" />
    is addressed in js in the following way:

    Code:
    document.WHO.ACTION.length
    Then how to replace that one with such a button:
    Code:
      <a data-role="button" data-inline="true" href="#page1" data-icon="arrow-l" data-iconpos="left">
                        Button
                    </a>
    Put it into a form yes, but value doesn't work here. How to do without?

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by eydg View Post
    Put it into a form yes, but value doesn't work here.
    of course, since it ain’t a form element, you can neither use the form access syntax, nor does the "button" have a value property.

    for access you’ll need standard DOM accessors (a là document.getElementById()) and for the value-property you have to use the according property of the <a> element (whatever that is in this case).

    NOTE: document.WHO.ACTION.length refers either to the size of the HTMLCollection returned by document.WHO.ACTION or, if it is a single element, undefined.

    ATTENTION: action is a property of the form element itself, so in the worst case, you don’t access a form element, but the target URL of the form (which, as a string, also has a length property).
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    79
    Thanks
    2
    Thanked 1 Time in 1 Post
    Okay, so there is this piece of code:

    Code:
     <a data-role="button" data-inline="true" data-direction="reverse" data-icon="arrow-r" data-iconpos="right"  id="participant1" ></a>
    
    <a data-role="button" data-inline="true" data-direction="reverse" data-icon="arrow-r" data-iconpos="right"  id="participant2" ></a>
    but according to dreamweaver, these do not go with "checked".

    How to refer to the status of such a radiobutton?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    One more time, those are *NOT* radio buttons.

    If they are something that DreamWeaver has NIGHTMARED-up for you, then you will need to refer to the DrunkWalker dccumentation to find out how DoofusWhacker uses them.

    If this is designed for use with something like ARIA, then refer to the ARIA documentation.

    But no matter what, those are *NOT* radio buttons.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Sep 2012
    Posts
    79
    Thanks
    2
    Thanked 1 Time in 1 Post
    Is it just you who hates the program, or should I beware mentioning it on the forum?

    I took the piece of code from a framework named codiga.

    Code:
                             <a data-role="button" data-inline="true" href="#page1" data-icon="arrow-l" data-iconpos="left">
                        Button
                    </a>
                    <a data-role="button" data-inline="true" data-direction="reverse" href="#page1" data-icon="arrow-r" data-iconpos="right">
                        Button
                    </a>
    The above does behave as a radiobutton, i.e. there are two butts and they switch as you press one.

    I need them to reference their status in script, but maybe i will just register on codiga if the code used is not universal enough.
    Last edited by eydg; 11-07-2012 at 12:13 PM.

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by eydg View Post
    The above does behave as a radiobutton, i.e. there are two butts and they switch as you press one.
    when they behave like a radio button does not mean they are radio buttons. that may not be a problem in GUI, but the programming interfaces of an <a> element and an <input> element are worlds apart:

    Code:
    // an <a> element (a fake radio button)
      interface HTMLAnchorElement : HTMLElement {
                 attribute DOMString       accessKey;
                 attribute DOMString       charset;
                 attribute DOMString       coords;
                 attribute DOMString       href;
                 attribute DOMString       hreflang;
                 attribute DOMString       name;
                 attribute DOMString       rel;
                 attribute DOMString       rev;
                 attribute DOMString       shape;
                 attribute long            tabIndex;
                 attribute DOMString       target;
                 attribute DOMString       type;
        void               blur();
        void               focus();
      };
    
    // <input> element (a real radio button)
      interface HTMLInputElement : HTMLElement {
                 attribute DOMString       defaultValue;
                 attribute boolean         defaultChecked;
        readonly attribute HTMLFormElement form;
                 attribute DOMString       accept;
                 attribute DOMString       accessKey;
                 attribute DOMString       align;
                 attribute DOMString       alt;
                 attribute boolean         checked;
                 attribute boolean         disabled;
                 attribute long            maxLength;
                 attribute DOMString       name;
                 attribute boolean         readOnly;
        // Modified in DOM Level 2:
                 attribute unsigned long   size;
                 attribute DOMString       src;
                 attribute long            tabIndex;
        // Modified in DOM Level 2:
                 attribute DOMString       type;
                 attribute DOMString       useMap;
                 attribute DOMString       value;
        void               blur();
        void               focus();
        void               select();
        void               click();
      };
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,184
    Thanks
    75
    Thanked 4,340 Times in 4,306 Posts
    It's okay to use DreamWeaver. Just don't expect it to produce very good JavaScript (or PHP or ASP, if you are using it for those) code. Depending on what you are doing, in fact, it might produce really horrible code.

    I don't think the code in this case is horrible, but it's certainly not made clear to you, the user of it, that what it is creating is in now way a radio button and you certainly can not treat it as such.

    What is happening is that DW is adding some kind of code BEHIND THE SCENES to make those <a> links *look* like radio buttons. And if you intend to use them to replace normal radio buttons, then you will have to very carefully read and understand the DW documentation on how they work and how you may be able to use them for that purpose.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •