|
|
|
Actually, according to the spec - all tags should be lowercase:
http://www.w3.org/TR/xhtml1/#h-4.8 Therefore, it should be <script...> Also, I ran the following through the validator at http://validator.w3.org and it no errors were found for having 2 forms of the same name. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Roller :: Editor</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <div id="content"><h3>Upload File</h3> <form name="uploadFiles" method="post" action="/roller/uploadFiles.do?method=upload" enctype="multipart/form-data"> Select an file from your computer<br/> <input type="file" name="uploadedFile" size="30"/><br/> <input type="submit" value="Submit"/> </form><h3>Manage Files</h3> <form name="uploadFiles" method="post" action="/roller/uploadFiles.do?method=delete"> <table class="rTable"> <tr class="rHeaderTr"> <td>Filename</td> <td>Size</td> <td>Delete</td> </tr> <tr class="rEvenTr"> <td class="rTd" colspan="3">No Files Found</td> </tr> </table> <input type="submit" value="Delete"></input> </form> <script type="text/javascript"> <!-- document.forms[0].elements[0].focus(); // --> </script> </div> </body> </html> You are correct if you use the DOCTYPE XHTML 1.0 Strict - you not only have to
replace the "name" attribute from "form" with and "id" attribute, you you can only have one "id" per unique identifier per page. in my development environment this happens a lot - because of the way that the app is organized,
there are several places where a page will have several forms that utilize the same Form bean, hence they are all called the same. A potential solution would be the adding of an optional id attribute as requiring knowledge of the number of forms in the page and depending on this not changing makes the resultant jsps rather brittle It's still not clear to me whether it's valid to have 2 forms of the same name. My previous post meant
that the tag uses <SCRIPT> now and should use <script>...I think you read it backwards :-). It's been my experience that the best way to set the focus is to refer to the
forms and field by number. If we did have a script that allowed us to set the form and field number, it could also fix the issue with the focus script not working in every browser. If anyone has submitted a path for setting the focus by number rather than name, please call my attention to it. -Ted. I've been thinking about this and need clarification if you dont mind Ted - is the 'designer'
calling the form number or do we need to figure this out in code? i.e. do we require the user to enter something like: <html:form action="/ProcessThis" focus="[n].lastname"> <html:text property="firstname"/> <html:text property="lastname"/> </html:form> Assuming yes: is this a zero based index? is there a better format? If not: Anyone give me a clue on how to go about finding out the index number of the form automatically Finally: I know this is tiresome but can you say yay or nay on whether there is a reason why I cant add an optional id attribute that is passed straight on to the resultant HTML and that therefore uniquely identifies the form so no form counting shennanigans are necessary? ta chanoch I don't know if there's a good way to find the form number automatically. To be honest, I really
think it's simplest just to code the JavaScript outside of tag. If you want to count the forms, that's easy enough to do with scriplets, <% int form=0;%> /... form[<%=form%>] <% form++; %> or to just maintain by hand. IHMO, some of this seems to transcend what might reasonably be expected of the lowly form tag. The focus= is a nice little gimme, but it my experience, it doesn't work in a lot of cases, so I don't even use it myself. It really doesn't do anything you couldn't do just as easily yourself. If someone were to submit a patch for a script that worked better, I'm sure it would be worth considering, but unless it can determine the script number automatically, it might be better to leave the more complex focus use-cases as an exercise for the developer. (Though, as a courtesy, we could document some techniques for alternate ways to set the focus.) There's also use-cases such as changing the focus after they use an element, like <html:select size="1" property="dispatch" onchange="document.forms[0].elements[1].focus()"> Should this be something that the tags should be doing too? I just think after the simplicity of the focus= tag, we start down a slipperly slope. So, I'm not saying no, I'm just asking why? (Hey, but if you fix it, send the patch!) ***
I've been looking at this bug off and on for the last few days, and in addition
to Ted's comments, no one has mentioned the fact that if you are creating multiple forms (with focus) as part of some iteration, each form will have a <script> right after the ending </form>. The only way to avoid this is to test during jsp execution, and if you are doing that, you might as well do it the right way (not use duplicate names). I've also compiled a nice collection of sample pages for testing all the possible choices. With duplicate forms with same name: NN4 sets the focus to the correct field on the last form NN6 sets the focus to the correct field on the first form Mozilla sets the focus to the correct field on the first form IE6 does not set anything and gives a script error message This issue is obviously handled very different among browsers and should not take up any more valueable time. Unless someone can submit a patch that works consistently and DOES NOT reduce the current functionality, this bug should remain closed. My solution, how to fix SAME NAMES IN ALL FORMS connected with same ACTION is : if the name of form is wrong, just try all forms, if they containt the element you wanna update.
Example : Replace this function showCalendar(year, month, day, pattern, formName, formProperty, event, startYear, endYear) { if (document.forms[formName].elements[formProperty].disabled) { return; } and fill the while cycle to find correct form function showCalendar(year, month, day, pattern, formName, formProperty, event, startYear, endYear) { i=1 while(document.forms[formName].elements[formProperty]==null&&i<20){ formName=i;r i++; } if (document.forms[formName].elements[formProperty].disabled) { return; } |
|||||||||||||||||||||||||||||||||||||||||||||||||
I agree with
the language attribute being removed for xhtml compliance but the rest of the tag isn't xhtml
compliant to begin with (ie. <SCRIPT> instead of <script>).