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 Problems!!?

Status
Not open for further replies.

JackD4ME

Programmer
Jun 4, 2002
228
US
Hi All,

I have a simple page that uses an anchor link to to call a function to take values from one field and drop it into another in the same form. Of course the code works in Firefox but not in IE6. IE bombs when it loads and wants to debug the calling line. Here is the function:

function sa(n){
if (n==1){
document.forms[0].sa.value = document.forms[0].pmaddr.value
document.forms[0].sc.value = document.forms[0].pmcity.value
document.forms[0].ss.value = document.forms[0].pmst.value
document.forms[0].sz.value = document.forms[0].pmzip.value
}
else{
document.forms[0].on1.value = document.forms[0].pmname.value
document.forms[0].oa1.value = document.forms[0].pmaddr.value
document.forms[0].oc.value = document.forms[0].pmcity.value
document.forms[0].os.value = document.forms[0].pmst.value
document.forms[0].oz.value = document.forms[0].pmzip.value
}
}

and here is the code that calls it:

<span class=sameas><a href="" onclick="sa(1);return false;">Same as Your Info</a></span>

Why does this not work?

Thanks in advance,
Jack :D
 
Give this a try real fast, it may be what's causing your problem:

Code:
<span class=sameas><a href="[!]javascript:void(0)[/!]" onclick="sa(1);return false;">Same as Your Info</a></span>

I did a test of this on my computer, and it took me to showing my desktop. (went up one directory).

[small]"King Coleman, live foreva!! Yeah buddy, light weight!!!"[/small]
<.
 
For every field involved, you have better to check the existence _if_ you are not sure for one reason or another their existence. Like this.
>document.forms[0].sa.value = document.forms[0].pmaddr.value
[tt]if (document.forms[0].sa && document.forms[0].pmaddr) {
document.forms[0].sa.value = document.forms[0].pmaddr.value
}[/tt]
etc...
Behaviour seems quite different ie vs moz when either of the fields does not exist, but both are not good. Otherwise, there should not be a big problem even one of the field name sa is the same as the function name sa().
 
I still get the problems when they exist. The weirdest part is that it works fine with FF. This is the first problem I've encountered with js cross-browser issues.
 
What is the actual error that you are getting?

Also, if your HTML file isn't too big, can you post it so we can take a look at it?



[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top