Hi every gurus here, i was encounter problem in passing value into url, please refer to the script below, i have batch of records which fetch from database and had a quantity box and update button on each (using onclick updateValue() function), i created javascript array to get each quantity box value and each value to be assign to the url qty, this is the problem exist now, the url qty cannot get its exact value from qty except I manually assigned the qty like qty[1], qty[2] and so on...for instance i got 3 quantity text box in a loop, each text box hold values like '1','2','3', assume i onclick update button for record two, url will pass qty values like &qty=1,2,3 instead of &qty=2, this will causes my script couldn't continually process without the exact value pass to qty!

can anyone advise how to solve this issue in proper method?


<script type="text/javascript">
function updateValue(itemId,itemQty){
	var maxNum = "<?php echo $nMax; ?>";
	var qty = new Array();
	
	for(var i=1; i<=maxNum; i++){
		qty[i] = document.getElementById('txtQty_'+i).value;
	}
	self.location = '?mode=usrCart&act=updateCart&itm='+itemId+'&qty='+qty;
}
</script>

Thanks.

var qty = new Array(1,2,3);
document.write('<a href="file_name.php?qty='+qty+'">click link</a>');

In this you can pass the array separated by comma.
Can you use this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.