www.webdeveloper.com
Results 1 to 11 of 11

Thread: Invisible buttons

  1. #1
    Join Date
    Dec 2002
    Posts
    2

    Invisible buttons

    Hello.
    I want to create a form, that when you click on a certain button the SUBMIT button becomes un-clickable. Is that possible? Thanks in advance.

  2. #2
    Join Date
    Dec 2002
    Location
    Sarasota, FL
    Posts
    63
    Take your pick...

    <button type="button" onclick="javascript:disabled=1; this.form.submit();">Click!</button>
    <input type="button" value="Click!" onclick="javascript:disabled=1; this.form.submit();" />

  3. #3
    Join Date
    Dec 2002
    Posts
    2
    Perhaps I did not make my post as cleaer as I intended.
    I want a form where when you click on one of the options the submit buttons clickability goes away, while if you click on a different option, it stays click-able. (How many words did I make up in that post )

  4. #4
    Join Date
    Dec 2002
    Location
    Sarasota, FL
    Posts
    63
    Ah, ok, I understand now. The first example is still good if you ever have a form where you REALLY don't want the user to click submit more than once (ex: credit card purchase form, etc).

    Here's a sample form that is more suited to your needs...

    Code:
    <form action="/index.htm" method="post">
      <input type="radio" name="choice" value="1" onclick="javascript:this.form.btnSubmit.disabled=1;" /> Disable<br />
      <input type="radio" name="choice" value="0" onclick="javascript:this.form.btnSubmit.disabled=0;" /> Enable<br />
      <input name="btnSubmit" type="submit" value="Click!" />
    </form>
    Hope that helps better.

  5. #5
    Join Date
    Dec 2002
    Location
    Sarasota, FL
    Posts
    63
    Oops, somehow a space ended up in "java script:" .. supposed to be "javascript:"

  6. #6
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Sceiron
    Oops, somehow a space ended up in "java script:" .. supposed to be "javascript:"
    Of cource you can safely leave out the javascript: entirely. It's not needed.

    However do put this in the head section of all your pages that has JS on them
    <meta http-equiv="Content-Script-Type" content="text/javascript">

  7. #7
    Join Date
    Dec 2002
    Location
    Sarasota, FL
    Posts
    63
    Depends on what you're scripting really, and how much of it you're using. If the only script you're using is within a link, then the "javascript:" method is easier if you think about it. The meta tag is useful if you have a lot of scripting going on and don't want to specify JavaScript every time.

  8. #8
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Sceiron
    Depends on what you're scripting really, and how much of it you're using.
    If the only script you're using is within a link, then the "javascript:" method is easier if you think about it.
    No, if you think about it the JavaScript: is invalid proprietary code and the meta tag is the correct way to specify the inline script language of a webpage.



    Authors should specify the default scripting language for all scripts in a document by including the following META declaration in the HEAD:

    <META http-equiv="Content-Script-Type" content="type">
    ...
    ...Documents that do not specify default scripting language information and that contain elements that specify an intrinsic event script are incorrect.
    http://www.w3.org/TR/html4/interact/....html#h-18.2.2

  9. #9
    Join Date
    Dec 2002
    Location
    Sarasota, FL
    Posts
    63
    I went back and checked on the use of the "javascript:" portion, and here's what I found.

    You are correct that it is not supposed to be used within event handlers, so I stand corrected there. However, it's not entirely invalid or proprietary. According to Javascript: The Definitive Guide published by O'Reilly, the "javascript:" identifier is to be used when executing JavaScript code directly from the HREF portion of an A tag, as in:

    <a href="javascript: function();">link</a>

  10. #10
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Sceiron
    According to Javascript: The Definitive Guide published by O'Reilly, the "javascript:" identifier is to be used when executing JavaScript code directly from the HREF portion of an A tag, as in:

    <a href="javascript: function();">link</a> [/B]
    You won't find that syntax in any offical W3C or EMCA documentation.

    Also Javascript has no buzziness what so ever to be located in the href="" of a link, that is what you got the onclick="" attribute for.

    That O'Reilly should probably brush up on his JS before he writes a book on the subject

    In short, that is invalid proprietary code and since I don't know of even one case where it would be required to make your code work I still maintain "you can safely leave out the java script: entirely. It's not needed."

  11. #11
    Join Date
    Nov 2002
    Posts
    4,473

    My two cents ...

    Originally posted by Stefan
    Javascript has no buzziness what so ever to be located in the href="" of a link
    I was surprised to see that the W3 definition of URL did not contain "javascript:", "about:" or "view-source:". I was also surprised by what they *did* include.

    BTW, there are no z's in "business" (at least in the United States).;-)
    Originally posted by Stefan
    you can safely leave out the javascript: entirely. It's not needed.
    Was this in reference to the onclick, or the href?

    In the case of the onclick (or any other) event, a call to a function will not need to be preferenced by a protocol, because the function is enclosed in a script tag that would establish the language. However, if for some odd reason you needed to specify some inline script (not my idea of good programming practice) that was not the browser's default or different from the document's META declaration, you would have to specify the language in the event handler.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles