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

Problems updating parent page

Status
Not open for further replies.

nohandlesleft254

IS-IT--Management
Apr 19, 2006
58
GB
Hi,

I'm rubbish with javascript so could someone have a quick scan of below and tell me why all my vars are appearing in the DelAddrCode field, and the other fields are getting a value of 'undefined'.

Thanks!

<!---- The call ---->
onClick="updateParent('#GetDeliveryAddresses.DelCode#,#GetDeliveryAddresses.Name#,#GetDeliveryAddresses.DelAddr1#,#GetDeliveryAddresses.DelAddr3#,#GetDeliveryAddresses.DelAddr4#,#GetDeliveryAddresses.Region#')
<!---- The Function ---->
function updateParent(DelAddrCode,ShipAddr0,ShipAddr1,ShipAddr4,ShipAddr5,Region)
{
opener.document.DeliveryAddress.DelAddrCode.value = DelAddrCode;
opener.document.DeliveryAddress.ShipAddr0.value = ShipAddr0;
opener.document.DeliveryAddress.ShipAddr1.value = ShipAddr1;
opener.document.DeliveryAddress.ShipAddr4.value = ShipAddr4;
opener.document.DeliveryAddress.ShipAddr5.value = ShipAddr5;
opener.document.DeliveryAddress.Region.value = Region;
self.close();
return false;
}
 
Try this:

onClick="updateParent('#GetDeliveryAddresses.DelCode#','#GetDeliveryAddresses.Name#','#GetDeliveryAddresses.DelAddr1#','#GetDeliveryAddresses.DelAddr3#','#GetDeliveryAddresses.DelAddr4#','#GetDeliveryAddresses.Region#')

(note the added single quotes)


---------------------
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Because you're only passing in one parameter to your function. Observe:
Code:
updateParent([red]--->>>>[/red]'#GetDeliveryAddresses.DelCode#,#GetDeliveryAddresses.Name#,#GetDeliveryAddresses.DelAddr1#,#GetDeliveryAddresses.DelAddr3#,#GetDeliveryAddresses.DelAddr4#,#GetDeliveryAddresses.Region#[red]---->>>[/red]')

As you can see in your function call, you're wrapping all the parameters in 1 set of single quotes. This means that all the values you're pulling from the database are being stuck in one string - the only parameter passed to the function. And that's the reason all the other parameters are pulling values of undefined. To remedy the situation put quotes around all the values you're passing:

Code:
updateParent([red]'[/red]#GetDeliveryAddresses.DelCode#[red]'[/red],[red]'[/red]#GetDeliveryAddresses.Name#[red]'[/red],[red]'[/red]#GetDeliveryAddresses.DelAddr1#[red]'[/red]..... etc)

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
boy, took me a while to type that..... [lol]

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
Your Javascript Seems fine.
Test it yourself
Code:
<html>
<head>
	<title>Reverse</title>
	<script>
function updateParent(DelAddrCode,ShipAddr0,ShipAddr1,ShipAddr4,ShipAddr5,Region) 
{
    	document.DeliveryAddress.DelAddrCode.value = DelAddrCode;
        document.DeliveryAddress.ShipAddr0.value = ShipAddr0;
        document.DeliveryAddress.ShipAddr1.value = ShipAddr1;
        document.DeliveryAddress.ShipAddr4.value = ShipAddr4;
        document.DeliveryAddress.ShipAddr5.value = ShipAddr5;
        document.DeliveryAddress.Region.value = Region;
    self.close();
    return false;
}
</script>
</head>
<body>

<form name="DeliveryAddress" id="DeliveryAddress">
	<input type="text" id="DelAddrCode" name="DelAddrCode">
	<input type="text" id="ShipAddr0" name="ShipAddr0">
	<input type="text" id="ShipAddr1" name="ShipAddr1">
	<input type="text" id="ShipAddr4" name="ShipAddr4">
	<input type="text" id="ShipAddr5" name="ShipAddr5">
	<input type="text" id="Region" name="Region">

	
</form>
<button onclick="updateParent(1,2,3,4,5);"> Click Me </button>

</body>
</html>

It must be your coldfusion.

I don't know the answer but my good friend Google does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top