Java problem- define a variable

Soldato
Joined
18 Oct 2002
Posts
3,245
Location
melbourne
I am trying to build a string using java but I get an error "item_number is undefined" on Line 43 (in red).

I basically want the script to add "PB" to the end of the output string. I think I need to tell it that "PB" is a text variable?

function setDelivery()
{
var descriptions = new Array(4);
descriptions[1]="Extra Shipping Charge: Same Day (Dublin Only)";
descriptions[2]="Extra Shipping Charge: Saturday Delivery (Ireland and Northern Ireland)";
descriptions[3]="Extra Shipping Charge: United Kingdom";
descriptions[4]="Extra Shipping Charge: Saturday Delivery (Dublin Only)";
var costs = new Array(4);
costs[1]=10; costs[2]=10; costs[3]=10; costs[4]=20;

var deliveryOption = getCheckedValue(document.orderForm.elements["delivery"]);

if (deliveryOption > 0)
{
document.addForm.amount.value = costs[deliveryOption];
document.addForm.item_name.value = descriptions[deliveryOption];
document.addForm.item_number.value = item_number + "PB";
if (navigator.appName != "Microsoft Internet Explorer" ||
navigator.appVersion.indexOf('MSIE 6.0') == -1) { document.addForm.target="_new"; }
document.addForm.submit();
} // END if
else { document.viewForm.submit(); }
} // END viewCart

Any help you could give me would be much appreciated. :)
 
Firstly its not java its javascript

I don't really know javascript but I think this will do what you require.

document.addForm.item_number.value += "PB";

Edit: Yeah see above :p
 
document.addForm.item_number.value = item_number + "PB";


What is "item_number"? If you are wanting to add "PB" to document.addForm.item_number.value then I would assume it is:

document.addForm.item_number.value = document.addForm.item_number.value + "PB";

Or, as has been said:

document.addForm.item_number.value += "PB";
 
Back
Top Bottom