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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE/Netscape - Compatability Lovefest with client side scripting.

Status
Not open for further replies.

WebWorker

Programmer
Aug 11, 1999
3
US
Gee you would never think this would be the case but...<br>
<br>
When I execute a javascript function (containing the statement below) from an onclick button event the following happens:<br>
<br>
In IE I get returned the count of array elements associated with the QuantityOrdered input text box. In other words I have 'n' number of like named input text boxes and am trying to determine the count.<br>
<br>
In IE..success...I get a dialog box count of the number of input text box elements.<br>
<br>
In Netscape I get....nothing!<br>
<br>
alert(document.all.item("QuantityOrdered").length);<br>
<br>
Now 'alert' is not the end goal here. I am attempting to wip through the collection of text boxes to do some edit checks. The edit check works correctly in IE but appears to be ignored in Netscape.<br>
<br>
Any ideas?<br>
<br>
Thanks in advance.
 
hmmmm....<br>
been too lond since I've done any advanced JavaScripting to give you a hard, working script; but I do know enough about Netscape JavaScripting that I *think* I'll be able to help...<br>
<br>
have you tried something like:<br>
<br>
var count;<br>
while n &lt;= 90;<br>
(<br>
if (document.forms[0].inputs[n] != "")<br>
{<br>
count=count++<br>
}<br>
}<br>
<br>
for your edit checking function? (I'm not sure if you'll have to use a sub-property of inputs[n] to check its contents...liek I said, a little rusty)<br>
<br>
-Robherc
 
Thanks for the response. <br>
<br>
Yeah, the sub-property needs to be the name of the specific text box that I am after. This is because I have an array of text boxes (dynamically generated) that all have the same name. I need to know the count of text boxes with the name 'QuantityOrdered'. IE serves it up with the example I gave in the alert box. The property '.length' when applied to an array of like minded elements gives you the count. Go figure. I have been trying to figure out what the Netscape flavor of this property might be. I have tried '.count' but that was way too obvious to work.<br>
<br>
Example:<br>
alert(document.all.item("QuantityOrdered").length);<br>
<br>
<br>
In the example statement that I just listed, IE returns the number of text box objects with the name 'QuantityOrdered'.<br>
<br>
Netscape ignores this statement. I may be reduced to generating the count in ASP and dynamically altering the javscript (in ASP) before sending it out to the browser. In other words:<br>
<br>
for (var i = 0; i &lt; document.all.item("QuantityOrdered").length; i++)<br>
<br>
gets changed to:<br>
<br>
for (var i = 0; i &lt; &lt;%=iCount%&gt;; i++) <br>
<br>
where &lt;%=iCount%&gt; is punched in by ASP before its travels to the browser!<br>
<br>
Kinda hacky but I gotta doos what I gotta doos.<br>
<br>
Cheers!
 
how about trying: document.formname.textboxname.length<br>
instead of: document.all.item("QuantityOrdered").length<br>
i.e.<br>
for (var i=0; i &lt; document.forms[0].QuantityOrdered.length; i++)<br>
<br>
or, even better:<br>
<br>
var i=document.forms[0].QantityOrdered.length;<br>
<br>
the las method would probably run *many* times faster so I would suggest using it first, no sense in loopin when it isn't *completely* necessary as a loop is the slowest routine aside from a wait, but waits are intended to be slow.<br>
<br>
<br>
-Robherc
 
Thanks for the clean up...I changed the loop delimeter to document.form.QuantityOrdered.length, but....Netscape still does not recoginze '.length' as the count of QuantityOrdered array elements like IE does!
 
hmmm<br>
<br>
for (j=0; 1&lt;1000; j++)<br>
{<br>
if document.form.inputs[j]==document.form.QuantityOrdered {i++}<br>
}<br>
<br>
Not quite sure on the inputs it might be a different word but I can't think of it if it is. This one *should* work with netscape....you might do a quick if/else if routine to determint IE/NS then run the above script for NS & the var i=document.form.QuantityOrdered.length for IE.<br>
<br>
Hope this helps;<br>
Robherc<br>
robherc@netzero.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top