Rxyz
03-08-2006, 03:02 PM
Want to get the first element that's in the <UL>
How do I get this?
Thanks.
How do I get this?
Thanks.
|
Click to See Complete Forum and Search --> : how to get the first element in <UL> Rxyz 03-08-2006, 03:02 PM Want to get the first element that's in the <UL> How do I get this? Thanks. Fang 03-08-2006, 03:19 PM document.getElementsByTagName('ul')[objIndex].getElementsByTagName('li')[0] Rxyz 03-09-2006, 08:36 AM Thankyou for your response. But have couple more questions. <UL><LI>Required</LI></UL> is the String that's returned using the tag <html:errors property="custName"/> I want to get just the Required field in it. I am sure there will be only one in the list always. In my jsp there will be more than one <UL> I am planning to send the <UL><LI>Required</LI></UL> String to a JS function <c:set var="custTypeSelectedError"><html:errors property="custTypeSelected"/></c:set> <script> var errorMsg = getErrorMsg(custTypeSelectedError); </script> function getErrorMsg(var error) { if(error != null) { document.forms[0].errorMsg.value = document.getElementsByTagName('ul')[objIndex].getElementsByTagName('li')[0]; ---- what will be objIndex??? return document.forms[0].errorMsg.value; } return null; } is this aproach right?? Fang 03-09-2006, 10:55 AM function getErrorMsg(error) { if(error != null) { // assume first unordered list in document return document.getElementsByTagName('ul')[0].getElementsByTagName('li')[0].innerHTML; // or firstChild.data if li only contains text. } return null; } ray326 03-09-2006, 10:26 PM I believe you have direct control of what is returned in that tag. The best way to fix the problem is to fix it at it's source, the content of the resource bundle where the error messages are defined. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |