Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onkeypress in fixed-size table (Netscape) 1

Status
Not open for further replies.

RoryMcQ

Programmer
Jun 8, 2000
8
US
I have an onkeypress routing in an input field within a table.  If I use WIDTH="640" in the TABLE tag, the table displays great but the onkeypress event won't fire.  If I use WIDTH="100%", the event will fire but the display isn't right.  It gets better.  If I adjust the input cell TD with WIDTH="60%", the display is corrected but the event will no longer fire.  All of these problems are observed in Netscape 4.7 but not in IE.  Any suggestions?
 
Dear Rory,<br><br>Could you extract only the HTML entities in question into a seprate file (page) and reproduce the behavior? If so post the code here for us to see.<br><br>-pete
 
Rory,<br>&nbsp;&nbsp;&nbsp;Can you explain what's wrong when the display isn't right?&nbsp;&nbsp;Seeing your code would sure help. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
I tried to paste in a sample that works in IE but not netscape, but the messageboard is executing my SQL and displaying my form to me with their
 
Dear Rory,<br><br>From your code:<br><br>&lt;input type=&quot;radio&quot; name=&quot;dems&quot; value=&quot;1&quot;&nbsp;&nbsp;onclick=&quot;setAmt(document.SchedCP.AmtContrDemParty,1)&quot;&gt;<br><br>Your onclick event is set to call a function named 'setAmt'. There is no function named 'setAmt' in the page. <br><br>If this is NOT the problem you are trying to solve, then you need to try much harder to explain the problem and reduce the code to the MINIMUM amount to produce the problem.<br><br>&quot;But, that's just my opinion... I could be wrong&quot;.<br>-pete
 
Ok, you have a point, that occurred to me after I put the code up.&nbsp;&nbsp;I believe I have now removed all references to non-existent routines & Netscape still isn't firing the onKeyPress event, while IE is.&nbsp;&nbsp;The code is still at<br><br>
 
Rory,<br>&nbsp;&nbsp;&nbsp;First of all,&nbsp;&nbsp;Netscape is very intolerant of errors in your code.&nbsp;&nbsp;In your case,&nbsp;&nbsp;inside the script tag,&nbsp;&nbsp;you need to change&nbsp;&nbsp;--&gt; to //--&gt; so it doesn't get processed as Javascript.&nbsp;&nbsp;Some advice: when things don't work right in Netscape, type javascript: in the url box.&nbsp;&nbsp;Netscape will display the Javascript console with any errors that occurred.<br>&nbsp;&nbsp;&nbsp;&nbsp;Secondly,&nbsp;&nbsp;Netscape's event handling is different from IE.&nbsp;&nbsp;In order to have a single handler that works in both Netscape and IE, I've found it easier to capture the events at the document or window level.&nbsp;&nbsp;In any case,&nbsp;&nbsp;with Netscape, you have to explicitly tell it to handle the event.&nbsp;&nbsp;This should get you started:<br><br>if (document.layers) <br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;document.captureEvents(Event.KEYPRESS);<br>}<br>document.onkeypress=showMe;<br><br>function showMe(e) {<br>&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(e.target.name);<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert (event.srcElement.name);<br>}<br><br>If you do this, remove the onkeypress from the input tags<br><br>I'd suggest brushing up on the Netscape event handling model:<br><br><A HREF=" TARGET="_new"> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Nick, thanks for attempting to point me in the right direction.&nbsp;&nbsp;Whenever I type Javascript in the navigation window, it brings me to <A HREF=" TARGET="_new"> tells me nothing was found. What do you mean by the javascript console?&nbsp;&nbsp;I put the // in and changed the first input field to onKeyPress = handlePress(event,this).&nbsp;&nbsp;This is the routine I really am shooting for, I just put showMe()in for debugging purposes.&nbsp;&nbsp;With width = &quot;640&quot;, it continues to ignore the onKeyPress.&nbsp;&nbsp;With width = &quot;100%&quot;, I got the respective alerts OnMouseOver, before I enter any data the first time I accessed it.&nbsp;&nbsp;The next time it just ignored the code.&nbsp;&nbsp;I realize you probably have seen enough, but just in case you're interested the 100% variation is at
 
Rory,<br><br>you forgot the colon at the end<br><br>javascript:<br><br>you'll know what the javascript console is when you see it.<br>By the way,&nbsp;&nbsp;the results don't get cleared from the console window unless you explicitly clear them,&nbsp;&nbsp;even if you close the console and open it again.<br><br>Once you clear up your errors, if you still have problems, let us know. <br><br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
You'd think that after almost 20 years in this business I'd pay attention to things like colons but hey, maybe senility is setting in.&nbsp;&nbsp;The console isn't displaying any errors, so I guess it'll be trial and error to get the onKeyPress firing regularly.&nbsp;&nbsp;I'll let you know if I get it.
 
I isolated the problem to a single table row which disables the onkeypress functionality in netscape.&nbsp;&nbsp;With this row, the routine does not fire.&nbsp;&nbsp;Without this row, the routines work correctly.&nbsp;&nbsp;I can see nothing functionally different in this row from the other 5, but it is the only row whose presence affects the execution of the code.&nbsp;&nbsp;I posted it at <A HREF=" TARGET="_new">
 
Rory dude, your cracking me up here, hehehehehe. Now this page :<br><br><A HREF=" TARGET="_new"> no 'showMe()' function, not to mention no &lt;html&gt; nor &lt;body&gt; tags. This has turned in to quite the adventure.<br><br>Ok so I took your code and produced this with it:<br>-----------------------------------------------------<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript&gt;<br>&lt;!--<br>function showMe(){<br><br>&nbsp;&nbsp;alert(&quot;showme&quot;);<br>}<br>//--&gt;<br>&lt;/SCRIPT&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;&lt;form&gt;<br>&lt;table border=1&gt;<br>&lt;tr&gt;<br>&lt;td height=&quot;36&quot;&gt;&lt;font <br> size=&quot;2&quot;&gt;6. Maine Children's Trust Incorporated&lt;/font&gt;&lt;/td&gt;<br>&lt;td align=right &gt; <br>&lt;input type=&quot;radio&quot; name=&quot;kids&quot; value=&quot;5&quot; &gt;$5  <br>&lt;input type=&quot;radio&quot; name=&quot;kids&quot; value=&quot;10&quot;&gt;$10  <br>&lt;input type=&quot;radio&quot; name=&quot;kids&quot; value=&quot;25&quot;&gt;$25 <br>&lt;input type=&quot;radio&quot; name=&quot;kids&quot; value=&quot;0&quot; &gt; Other &lt;/td&gt;<br>&lt;td align=&quot;right&quot; <br> height=&quot;36&quot;&gt;&lt;font size=&quot;2&quot;&gt;6&lt;/font&gt; &lt;input type=&quot;text&quot;<br> name=&quot;AmtContrMEChild&quot; size=&quot;12&quot; <br> onKeyPress=&quot;showMe()&quot;&gt;&lt;/td&gt;<br>&lt;/tr&gt;&lt;/table&gt;<br>&lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>------------------------------------------------<br>And it works in IE4-5 and Nutscrap 4.06<br><br>Hope this helps<br>-pete
 
Palbano, I thought I made it clear that the &quot;problem&quot; page contained only the line which seemed to cause the problem, not an entire functioning page.&nbsp;&nbsp;At any rate, further experimentation was done, & the end result seemed to indicate a limitation on how many form items Netscape could access successfully, based on the page structure.&nbsp;&nbsp;When I organize the array into 3 tables of two rows each, it works fine.&nbsp;&nbsp;Any other organization results in some of the input tags not firing &quot;onKeyPress&quot;, though no errors are shown on the Javascript console.&nbsp;&nbsp;It would seem Netscape has a ways to go in providing a reliable programming platform with adequate diagnostics for troubleshooting.
 
Rory,<br>&nbsp;&nbsp;&nbsp;My experience is that you always have to fight with Netscape to get things to work to your satisfaction.&nbsp;&nbsp;Maybe this will change with Netscape 6, since it;s a total rewrite. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
event handlers in tables is not supported by Netscape.&nbsp;&nbsp;I have seen this same problem on other discussion boards.&nbsp;&nbsp;I know you can get event handlers to operate, usually inconsistently, in tables within Netscape.&nbsp;&nbsp;But I think this is more of a fluke than anything.&nbsp;&nbsp;Be assured that event handlers are not directly supported in Netscape.<br><br>Russ
 
P.S.&nbsp;&nbsp;NickBulka.&nbsp;&nbsp;You're right, Netscape 6.PR1 is available and does support a number of 'new' things that makes it easier to write for.&nbsp;&nbsp;It's available in Beta.&nbsp;&nbsp;I don't much like the appearance, but it sure is fast.&nbsp;&nbsp;Of course, Netscape has always been faster than IE on my system for some reason, but this is even faster.
 
Dear Rory,<br><br>&gt;I thought I made it clear...<br><br>Yes, you are correct. Now that I can see the result, when I go back and read your previous posts it makes sense to me. I guess I just didn't get it. Sorry for the confusion, I'm glad you have it working now.<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top