charales said the following on 6/2/2006 4:13 PM:
Hi everyone!
Hi, and please don't post attachments or binary files here. Thank you.
I'm having this problems with javascript. If you go to:
http://www.nikonistas.com/es_home/nikon2.html
you'll find at the top-left corner the typical username-password form with
the "send" button that actually does a javascript:envia(); (envia means send
in spanish).
OK. Bad idea but ok.
The problem is that it does not work, no matter what I do it does not send
the information. I have Java and Javascrips activated and up to date.
Does anyone know what the problem could be?
Yes, there are many many problems with that page and it's code other
than your form not getting submitted.
This is your envia function:
function envia()
{
if (nav=="ie")
//Please, tell us that you are not trying to distinguish
//IE based on the navigator object? Besides, it is not
//needed in this function anyway.
{
if (f1.elements[0].value == "")
//There is where your IE behavior is involved. f1 is the
//name of the form. Just refer to the form properly
// and you lose all interest in the browser.
{
alert("El número de nikonista es un campo obligatorio.");
f1.elements[0].focus();
//return (false);
}
else
if (f1.elements[1].value == "")
{
alert("El password es un campo obligatorio.");
f1.elements[1].focus();
//return (false);
}
else f1.submit();
}
else {
//This is the non-nav == "ie" branch.
if (document.clave.document.f1.elements[0].value == "")
//one look in the FF console tells you that document.clave
//has no properties.
if (document.f1.elements[0].value == "")
{
alert("El número de nikonista es un campo obligatorio.");
document.clave.document.f1.elements[0].focus();
//return (false);
}
else
if (document.clave.document.f1.elements[1].value == "")
//ditto here, document.clave has no properties
{
alert("El password es un campo obligatorio.");
document.clave.document.f1.elements[1].focus();
//return (false);
}
else document.clave.document.f1.submit();}
}
The entire function, re-written:
function envia()
{
if (document.f1.elements[0].value == "")
{
alert("El número de nikonista es un campo obligatorio.");
document.f1.elements[0].focus();
}
else
{
if (document.clave.document.f1.elements[1].value == "")
{
alert("El password es un campo obligatorio.");
document.f1.elements[1].focus();
}
else
{
document.f1.submit();
}
}
}
Although the idea of using the image the way you do eludes me:
<input type="submit" style="background: url(ok_ov.gif);background-color:
orange;width:20px;height:20px">
Would be a start towards a better idea.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/