Today, I meet a problem.
A checkbox and a text in a page, if I want the text is disabled unless the checkbox is checked, how can I write that javascript?
Anyone who can help me?
Today, I meet a problem.
A checkbox and a text in a page, if I want the text is disabled unless the checkbox is checked, how can I write that javascript?
Anyone who can help me?
Code:<form action=""> <input type="text" name="tr" disabled="1"><input type="checkbox" onclick="if (this.checked){this.form.tr.disabled=0}else{this.form.tr.disabled=1}"> </form>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Aha!, that works.
Thank you, jscheuer1 !!!
method is required.Originally Posted by John
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
No, it isn't.Originally Posted by Twey
It defaults to the GET request method. Only the action attribute is required, though an empty value might not be a good idea: IE resolves empty href attributes incorrectly, so it's feasible that others will have similar issues not restricted to that particular attribute.
Mike
Oh, so it isn't. My apologies -- could have sworn I'd had trouble validating that before.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thanks, Mike. I was out to sea on this one. Only reason I included it at all was that it is in my editors' 'come with' form boiler plate. But, as previously noted in these forums, others may use the value of their choice. I suppose if no action is truly desired:
would do. I have never seen this cause a problem though, leaving it blank, but I suppose anything is possible, as you note.Code:action="javascript:void(0);"
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
If that works, it will cause nothing to happen when the form is submitted. This is different to the effect of an empty action or "?", which will cause the form to be submitted to the current page.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Well, we're talking here about a form that never gets submitted. I would think that if a user were to adapt the code to a form that does get submitted, they would have to set the values that impact submission behavior appropriately to their objectives. Submission or lack thereof has no impact on the functionality of my solution to the original question. All this is really beyond the scope of the question posed and answered originally. I think I will give Twey a nitpicking award for this one and Mike a clarification of a nit pick award though, he was mostly just responding to an obvious (to him) error on Twey's part.
Last edited by jscheuer1; 05-10-2006 at 07:43 PM.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Heh... (wears "pedant of the year" award with pride)
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks