Invisible buttons

liunx

Guest
Hello.<br />
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.<!--content-->Take your pick...<br />
<br />
<button type="button" onclick="javascript:disabled=1; this.form.submit();">Click!</button><br />
<input type="button" value="Click!" onclick="javascript:disabled=1; this.form.submit();" /><!--content-->Perhaps I did not make my post as cleaer as I intended.<br />
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 :p )<!--content-->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).<br />
<br />
Here's a sample form that is more suited to your needs...<br />
<br />
<br />
<form action="/index.htm" method="post"><br />
<input type="radio" name="choice" value="1" onclick="javascript:this.form.btnSubmit.disabled=1;" /> Disable<br /><br />
<input type="radio" name="choice" value="0" onclick="javascript:this.form.btnSubmit.disabled=0;" /> Enable<br /><br />
<input name="btnSubmit" type="submit" value="Click!" /><br />
</form><br />
<br />
<br />
Hope that helps better.<!--content-->Oops, somehow a space ended up in "java script:" .. supposed to be "javascript:"<!--content-->Originally posted by Sceiron <br />
Oops, somehow a space ended up in "java script:" .. supposed to be "javascript:" <br />
<br />
Of cource you can safely leave out the javascript: entirely. It's not needed.<br />
<br />
However do put this in the head section of all your pages that has JS on them<br />
<meta http-equiv="Content-Script-Type" content="text/javascript"><!--content-->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.<!--content-->Originally posted by Sceiron <br />
Depends on what you're scripting really, and how much of it you're using. <br />
If the only script you're using is within a link, then the "javascript:" method is easier if you think about it. <br />
<br />
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.<br />
<br />
<br />
<br />
<br />
Authors should specify the default scripting language for all scripts in a document by including the following META declaration in the HEAD:<br />
<br />
<META http-equiv="Content-Script-Type" content="type"><br />
...<br />
...Documents that do not specify default scripting language information and that contain elements that specify an intrinsic event script are incorrect. <br />
<!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2">http://www.w3.org/TR/html4/interact/scr ... l#h-18.2.2</a><!-- m --><!--content-->I went back and checked on the use of the "javascript:" portion, and here's what I found.<br />
<br />
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:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript: function();">link</a><!--content-->Originally posted by Sceiron <br />
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:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript: function();">link</a> [/B] <br />
<br />
You won't find that syntax in any offical W3C or EMCA documentation.<br />
<br />
Also Javascript has no buzziness what so ever to be located in the href=http://www.webdeveloper.com/forum/archive/index.php/"" of a link, that is what you got the onclick="" attribute for.<br />
<br />
That O'Reilly should probably brush up on his JS before he writes a book on the subject ;)<br />
<br />
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." :)<!--content-->Originally posted by Stefan<br />
Javascript has no buzziness what so ever to be located in the href=http://www.webdeveloper.com/forum/archive/index.php/"" of a link<br />
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.<br />
<br />
BTW, there are no z's in "business" (at least in the United States).;-)<br />
Originally posted by Stefan<br />
you can safely leave out the javascript: entirely. It's not needed.<br />
Was this in reference to the onclick, or the href?<br />
<br />
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.<!--content-->
 
Back
Top