will said:
Thanks for all that DU. Its been a while since Ive had to delve into
Javascript so the help is appreciated.
Yeah I thought this may be my problem. How do I plus one without
plusing one? if you see what I mean. Just temporarily.. so kind of
like:
var n = f (+1);
so f stays the same and the resulting number is used.
Cheers
W
Avoid adding more variables and code into your script. First try to
understand the logical bug in your script. Your problem has nothing to
do with an insertCell difficulty. So do not add more variables.
init() is called twice: as the document loads and as the user clicks the
button: that's a logical bug here.
If "f" is going to be a row iterator, then use it as a global variable
and don't query the table.rows.length at all. So, IMO, the init()
function is useless, not necessary, just makes the code more complex.
When facing logical bugs, you should try to simplify your
program/functions/scripts, not make it more complex.
Use Venkman javascript debugger to monitor watches and local variable
values, otherwise use alert to output values.
So, here, you can safely delete
document.formDisplay.nnum.value = n;
document.formDisplay.fnum.value = f;
and its related html code.
If "f" is going to be a very important variable in your code, then give
it a meaningful, intuitive, self-explanatory identifier. Others
reviewing your code, helping out, or yourself in 3 months from now will
save time trying to figure out the script. I assure you that such simple
basic and sane coding practices save a lot of time and frustrations in
the long run. Tutorials, Netscape DevEdge, MSDN columns all say the same
on this issue and on debugging.
Always make sure your whole html markup is valid and validated in the
first place; use a full doctype declaration. You make your page
compliant, interoperable and you avoid problems of all kinds later. You
eliminate possible sources of differential rendering when you write/test
your script functions.
var input = document.createElement('INPUT');
input.setAttribute('type', 'file');
input.name = 'imageup' + f;
input.onchange = function () { addInput(); };
This above code will create another line when just choosing a file,
while the other code will do the same if clicking the "Select another
file" button: so, you have here a logical bug, a duplication. The
input.onchange = function () { addInput(); };
should be removed entirely.
Drop entirely the setAttribute call in your code: you don't need that
and there is a much better, more reliable way to assign a type to a
input DOM node:
input.setAttribute('type', 'file');
should be
input.type = "file";
I think you can safely drop the entire block testing document.all as I
would be very much surprised if MSIE 4 can embed new additional and
functioning form elements into a form. Since MSIE 5+ supports DOM-1
methods, then you can safely drop the whole block of
if(document.all). Anyway, you should first try to support MSIE 6, NS
7.x, Opera 7.x
action="whatever" is not valid; action="" is ok though.
You should not try to remove the "old" buttons for usability reasons.
The user might want to change his mind.
I did your valid webpage and it works perfectly, impeccably, flawlessly
on Opera 7.11, MSIE 6 for Windows and Mozilla 1.4 and I think it has a
better design than in your original page (it has only 1 "Select another
file" button). I will upload it later.
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html