Please excuse me. I attempted to post this twice before, but I now realize I must do it from the email address in which I registered. Anyway, my problem is that I don't believe that an onfocus handler can rely on getNodeAttribute to retrieve the contents of another node. I created a small example of this (see below). In my example, I have two text fields named text1 and text2 which I believe are remarkably original names :). I attach an onfocus handler to text2 whose job is to display the content of text1 in an alert message. It uses getNodeAttribute to attempt to retrieve the contents of text1, but this fails. Instead getNodeAttribute returns null. On the other hand if I use the less desirable instruction "textVal = TheForm.text1.value;" it works correctly. So I don't need a workaround, I just want to understand why getNodeAttribute fails to retrieve the value in this case. My preference is to use MochiKit functions wherever possible. Thanks in advance.
Mike <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> <script src="MochiKit.js" type="text/javascript"> </script> <script type="text/javascript"> function displayText1(e) { //Note if I substitute for the following line the following //this script will work properly. //textVal = document.TheForm.text1.value; text1Val = getNodeAttribute(document.TheForm.text1, 'value'); alert('Text1 contains ' + text1Val); } connect(self, 'onload', function(e) { connect(TheForm.text2, 'onfocus', displayText1); } ); </script> <body> <form name=TheForm> <input type=text name=text1 \> <input type=text name=text2 \> </form> </body> </html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> <script src="MochiKit.js" type="text/javascript"> </script> <script type="text/javascript"> function displayText1(e) { //Note if I substitute for the following line the following //this script will work properly. //textVal = document.TheForm.text1.value; text1Val = getNodeAttribute(document.TheForm.text1, 'value'); alert('Text1 contains ' + text1Val); } connect(self, 'onload', function(e) { connect(TheForm.text2, 'onfocus', displayText1); } ); </script> <body> <form name=TheForm> <input type=text name=text1 \> <input type=text name=text2 \> </form> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---
