Form Name...

1

116

I have aparticular form that every time I enter the form name in, that after
closing the page and re-opening it, the name disappears. I even attempted to
enter it directly into the page code. Still it disappears. Any thoughts? I
believe this to be the issue to why I am having trouble running a proven
jscript on this page.

David
 
J

Jon Spivey

Without knowing what could be causing this it's usually easier not to name
forms, rather pass the form to your function. Say you have some script that
runs onsubmit

<form onsubmit="return doForm(this);">
type frontpage here <input type="text" name="a" />
<input type="submit" />
</form>

<script type="text/javascript">
function doForm(f){
if(f.a.value!='frontpage'){alert('type frontpage');return false;}
return true;
}
</script>

Apart from removing issues with form names scripts written this way are also
much easier to re-use. Alternative is to reference by index, eg
document.forms[0] <- 1st form on the page
document.forms[1] <- 2nd form on the page
etc

With either of the above approaches the form doesn't need a name atall.

Cheers,
Jon
http://MyMobileDeal.com
 
1

116

Thank you. This was the reason for my script not to work. The
document.forms[#].

David

Jon Spivey said:
Without knowing what could be causing this it's usually easier not to name
forms, rather pass the form to your function. Say you have some script that
runs onsubmit

<form onsubmit="return doForm(this);">
type frontpage here <input type="text" name="a" />
<input type="submit" />
</form>

<script type="text/javascript">
function doForm(f){
if(f.a.value!='frontpage'){alert('type frontpage');return false;}
return true;
}
</script>

Apart from removing issues with form names scripts written this way are also
much easier to re-use. Alternative is to reference by index, eg
document.forms[0] <- 1st form on the page
document.forms[1] <- 2nd form on the page
etc

With either of the above approaches the form doesn't need a name atall.

Cheers,
Jon
http://MyMobileDeal.com

116 said:
I have aparticular form that every time I enter the form name in, that
after
closing the page and re-opening it, the name disappears. I even attempted
to
enter it directly into the page code. Still it disappears. Any thoughts?
I
believe this to be the issue to why I am having trouble running a proven
jscript on this page.

David


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top