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

Works in IE, not Firefox - anything obvious here?

Status
Not open for further replies.

tsp1lrk72

IS-IT--Management
Feb 25, 2008
100
US
Just using this code to fill in contact info if it's the same to save typing and it works fine in IE but not Firefox... any ideas?

Code:
<script language="javascript" type="text/javascript">
function fill_contact()
	{
	if (frmContact.chbsame.checked == true)
		{
		frmContact.vnds_scntct_fnm.value = frmContact.vnds_cntct_fnm.value;
		frmContact.vnds_scntct_lnm.value = frmContact.vnds_cntct_lnm.value;
		frmContact.vnds_cntct_adr1.value = frmContact.vnds_bill_adr1.value;
		frmContact.vnds_cntct_adr2.value = frmContact.vnds_bill_adr2.value;
		frmContact.vnds_cntct_city.value = frmContact.vnds_bill_city.value;
		frmContact.vnds_cntct_zip.value = frmContact.vnds_bill_zip.value;
		frmContact.vnds_cntct_ph.value = frmContact.vnds_phone.value;
		frmContact.vnds_cntct_email.value = frmContact.vnds_email.value;
		frmContact.vnds_cntct_fax.value = frmContact.vnds_fax.value;
		var i = frmContact.vnds_bill_state.selectedIndex;
		frmContact.vnds_cntct_state.selectedIndex = i;
		var i = frmContact.vnds_country.selectedIndex;
		frmContact.vnds_cntct_cntry.selectedIndex = i;
		}
	else 
		{
		frmContact.vnds_scntct_fnm.value = "";
		frmContact.vnds_scntct_lnm.value = "";
		frmContact.vnds_cntct_adr1.value = "";
		frmContact.vnds_cntct_adr2.value = "";
		frmContact.vnds_cntct_city.value = "";
		frmContact.vnds_cntct_zip.value = "";
		frmContact.vnds_cntct_ph.value = "";
		frmContact.vnds_cntct_email.value = "";
		frmContact.vnds_cntct_fax.value = "";
		frmContact.vnds_cntct_cntry.selectedIndex = 0;
		frmContact.vnds_cntct_state.selectedIndex = 0;
		}
	}
</script>
 
Hi

Where gets frmContact its value ? So far it looks like you followed the sloppy coding style promoted by Explorer. Try this :
JavaScript:
[b]function[/b] [COLOR=darkgoldenrod]fill_contact[/color][teal]()[/teal]
[teal]{[/teal]
  [b]if[/b] [teal]([/teal]frmContact[teal].[/teal]chbsame[teal].[/teal]checked[teal])[/teal] [teal]{[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_scntct_fnm[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_fnm[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_scntct_lnm[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_lnm[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_adr1[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_bill_adr1[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_adr2[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_bill_adr2[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_city[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_bill_city[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_zip[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_bill_zip[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_ph[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_phone[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_email[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_email[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_fax[teal].[/teal]value [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_fax[teal].[/teal]value[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_state[teal].[/teal]selectedIndex [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_bill_state[teal].[/teal]selectedIndex[teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_cntry[teal].[/teal]selectedIndex [teal]=[/teal] document[teal].[/teal]frmContact[teal].[/teal]vnds_country[teal].[/teal]selectedIndex[teal];[/teal]
  [teal]}[/teal] [b]else[/b] [teal]{[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_scntct_fnm[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_scntct_lnm[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_adr1[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_adr2[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_city[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_zip[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_ph[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_email[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_fax[teal].[/teal]value [teal]=[/teal] [green][i]""[/i][/green][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_cntry[teal].[/teal]selectedIndex [teal]=[/teal] [purple]0[/purple][teal];[/teal]
    document[teal].[/teal]frmContact[teal].[/teal]vnds_cntct_state[teal].[/teal]selectedIndex [teal]=[/teal] [purple]0[/purple][teal];[/teal]
  [teal]}[/teal]
[teal]}[/teal]

Feherke.
 
Something like this:
Code:
function fill_contact()
    {
    with (document.getElementById('frmContact'))
        {
        if (chbsame.checked == true)
            {
            vnds_scntct_fnm.value = vnds_cntct_fnm.value;
            vnds_scntct_lnm.value = vnds_cntct_lnm.value;
            vnds_cntct_adr1.value = vnds_bill_adr1.value;
            vnds_cntct_adr2.value = vnds_bill_adr2.value;
            vnds_cntct_city.value = vnds_bill_city.value;
            vnds_cntct_zip.value = vnds_bill_zip.value;
            vnds_cntct_ph.value = vnds_phone.value;
            vnds_cntct_email.value = vnds_email.value;
            vnds_cntct_fax.value = vnds_fax.value;
            var i = vnds_bill_state.selectedIndex;
            vnds_cntct_state.selectedIndex = i;
            var i = vnds_country.selectedIndex;
            vnds_cntct_cntry.selectedIndex = i;
            }
        else 
            {
            vnds_scntct_fnm.value = "";
            vnds_scntct_lnm.value = "";
            vnds_cntct_adr1.value = "";
            vnds_cntct_adr2.value = "";
            vnds_cntct_city.value = "";
            vnds_cntct_zip.value = "";
            vnds_cntct_ph.value = "";
            vnds_cntct_email.value = "";
            vnds_cntct_fax.value = "";
            vnds_cntct_cntry.selectedIndex = 0;
            vnds_cntct_state.selectedIndex = 0;
            }
        }
    }

You just need to make sure that the form has the ID "frmContact".

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top