Jump to content

Array With Valid Value Keeps Inserting As 0 Into Valid Text Field. Why Could This Be Happening?


Greywacke
 Share

Recommended Posts

hi there,i hope someone can help, i don't see the wall for the doors to the solution.i have a form named form_suppliers

<input type="text" name="text_creditlowerminimum" id="text_creditlowerminimum" accesskey="l" tabindex="24" />

.the script inserts the following array, with element 11 having a value, it is alerted before attempting to insert the code with

document.form_suppliers.text_creditlowerminimum.value = val[11];

.the array alerts as the following:

8,http://www.continentalmotors.co.za/,281 Koeberg Road, Brooklyn, Cape Town,Dries,Lubbe,Owner,johncox@live.co.za,27215114787,820,200,Your PAYG credit limit is low. Please make a minimum payment of R1,000 ASAP and email confirmation to canopy@canopyxchange.za.net,100,Your PAYG credit limit is VERY LOW. To avoid not being disregarded during the automated lead/supplier matching process, make a minimum payment of R1,000 ASAP and email bank payment confirmation to canopy@canopyxchange.za.net,;;,Jaap Venter,info@canopyxchange.za.net,http://maps.google.co.za/maps/ms?ie=UTF8&msa=0&msid=102191045390808171562.0004803e348b3d5002e62&ll=-33.821014,18.537176&spn=0.016347,0.033023&z=16,0,Bakkie Canopy (western_cape and children);:;2;1;11;canopy_req;new_colour_coded;:;1;1;11;canopy_req;new_white;:;12;1;11;canopy_req;pre-owned_colour_coded;:;11;1;11;canopy_req;pre-owned_white;:;289;1;11;Requirement;New - Colour-coded;:;288;1;11;Requirement;New - White;:;287;1;11;Requirement;Pre-owned - Colour-coded;:;286;1;11;Requirement;Pre-owned - White;.;Bakkie Canopy (Western Cape - Cape Town and children);:;2;1;28;canopy_req;new_colour_coded;:;1;1;28;canopy_req;new_white;:;12;1;28;canopy_req;pre-owned_colour_coded;:;11;1;28;canopy_req;pre-owned_white;:;289;1;28;Requirement;New - Colour-coded;:;288;1;28;Requirement;New - White;:;287;1;28;Requirement;Pre-owned - Colour-coded;:;286;1;28;Requirement;Pre-owned - White,Bakkie Canopy (western_cape and children);:;2;1;11;canopy_req;new_colour_coded;:;1;1;11;canopy_req;new_white;:;12;1;11;canopy_req;pre-owned_colour_coded;:;11;1;11;canopy_req;pre-owned_white;.;Bakkie Canopy (Western Cape - Cape Town and children);:;289;1;28;Requirement;New - Colour-coded;:;288;1;28;Requirement;New - White;:;287;1;28;Requirement;Pre-owned - Colour-coded;:;286;1;28;Requirement;Pre-owned - White
note that element 11 contains the credit lower minimum. however, this will not insert into the field, val elements 9 10 and 12 insert however, as well as the rest of the elements. the reason these are retrieved from a string, is because they are stored in a list box as values. this value is split by ;,; initially from the value (the alert contents shows this to be working correctly), the substrings are delimited by ;:;.my question is, why will this array element not insert into the value of the text field? any possible reasons why?
Link to comment
Share on other sites

the javascript function that inserts this, with the alert commented - is as follows:

// onselect event handlerdocument.form_suppliers.list_suppliers.onchange = function () {	supplier = this.selectedIndex;	if (supplier > -1) {		var val = this.options[supplier].value.split(";,;");		//alert(val);		document.form_suppliers.text_suppliername.value = trim(this.options[this.selectedIndex].text,"");		document.form_suppliers.text_supplierw3address.value = val[1];		document.form_suppliers.textbox_supplieraddress.value = val[2];		document.form_suppliers.text_contactfirstname.value = val[3];		document.form_suppliers.text_contactsurname.value = val[4];		document.form_suppliers.text_contactposition.value = val[5];		document.form_suppliers.text_contactemail.value = val[6];		document.form_suppliers.text_contacttelephonenumber.value = val[7];		document.form_suppliers.text_creditbalance.value = val[8];		document.form_suppliers.text_creditupperminimum.value = val[9];		document.form_suppliers.textbox_credituppermessage.value = val[10];		document.form_suppliers.text_creditlowerminimum.value = val[11];		document.form_suppliers.textbox_creditlowermessage.value = val[12];		var vtdata = val[13].split(";");		document.form_suppliers.text_vturl.value = vtdata[0];		document.form_suppliers.text_vtusr.value = vtdata[1];		document.form_suppliers.text_vtkey.value = vtdata[2];		document.form_suppliers.text_accmgr.value = val[14];		document.form_suppliers.text_accmgremail.value = val[15];		document.form_suppliers.text_googlemapsurl.value = val[16];		for (var i = 0; i < document.form_suppliers.menu_status.options.length; i++) {			if (document.form_suppliers.menu_status.options[i].value == val[17]) {				document.form_suppliers.menu_status.options[i].selected = true;			} else {				document.form_suppliers.menu_status.options[i].selected = false;			}		}		document.form_suppliers.menu_attributes.options.length = 1;		document.form_suppliers.list_supplierattributes.options.length = 0;		if (val[18]) {			var val1 = val[18].split(";.;");			for (var e = 0; e < val1.length; e++) {				var opt1 = document.createElement("option");				var arr = val1[e].split(";:;");				//(arr);				opt1.text = arr[0];				// service name (region)				opt1.value = 0;					// zero value				opt1.disabled = true;			// prevent title from being selected				var sel1 = document.getElementById("menu_attributes");				try {					sel1.add(opt1, null); 		// standards compliant; doesn't work in IE				} catch(ex) {					sel1.add(opt1); 			// IE only				}				for (var i = 1; i < arr.length; i++) {					var opt2 = document.createElement("option");					opt2.text = "\u00a0\u00a0\u00a0\u00a0\u00a0" +			// attribute description = attribute value					arr[i].split(";")[3] + " = " + arr[i].split(";")[4];					opt2.value = arr[i].split(";")[0] + "," +				// attribute, service & region id array					arr[i].split(";")[1] + "," +					arr[i].split(";")[2];					try {						sel1.add(opt2, null); 								// standards compliant; doesn't work in IE					} catch(ex) {						sel1.add(opt2); 									// IE only					}				}			}		}		if (val[19]) {			var val2 = val[19].split(";.;");			for (var e = 0; e < val2.length; e++) {				var opt1 = document.createElement("option");				var arr = val2[e].split(";:;");				//alert(arr);				opt1.text = arr[0];				// service name (region)				opt1.value = 0;					// zero value				opt1.disabled = true;			// prevent title from being selected				var sel1 = document.getElementById("list_supplierattributes");				try {					sel1.add(opt1, null); 		// standards compliant; doesn't work in IE				} catch(ex) {					sel1.add(opt1); 			// IE only				}				for (var i = 1; i < arr.length; i++) {					var opt2 = document.createElement("option");					opt2.text = "\u00a0\u00a0\u00a0\u00a0\u00a0" +			// attribute description = attribute value					arr[i].split(";")[3] + " = " + arr[i].split(";")[4];					opt2.value = arr[i].split(";")[0] + "," +				// supplier, service, attribute, & region id array					arr[i].split(";")[1] + "," +					arr[i].split(";")[2];					try {						sel1.add(opt2, null); 								// standards compliant; doesn't work in IE					} catch(ex) {						sel1.add(opt2); 									// IE only					}				}			}		}	}}

Link to comment
Share on other sites

yes it does, the problem was with duplicate fields by that name in the form.excuse the delay, this issue was resolved :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...