3 Replies - 7370 Views - Last Post: 20 March 2009 - 11:17 AM

#1 bucko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-June 08

Jquery .load Problem

Post icon  Posted 20 February 2009 - 09:00 AM

I am trying to submit multiple form items with jquery .load.
If I only include 1 variable pair that uses document.getElementById, it works as expected. When I include an additional pair after this, It creates error. Any Ideas how to include more than one markup pair using this function.

	   <td><select name="option1" id="option1">
							  <option value="4">Small						-$1.00						</option>
					   <option value="5">Large						+$1.00						</option>
					 </select></td>
	 </tr>

		 </table>
		 </div>
 <div class="buttons">
   <table>
	 <tr>
	   <td align="right">
				  <input class="button"type="button" id="Add_to_Cart" value="Add to Cart" onclick="$('#mini_cart').load('index.php?controller=addtocart&amp;action=add&amp;item=15&amp;quantity='+document.getElementById('quantity').value&amp;option1='+document.getElementById('option1').value),document.getElementById('Add_to_Cart').value='Added to Cart';">

			   &nbsp;

			   <select name="quantity" id="quantity">
										   <option value="1">1</option>
										   <option value="2">2</option>
										   <option value="3">3</option>
										   <option value="4">4</option>
										   <option value="5">5</option>

												  </select>   


Is This A Good Question/Topic? 0
  • +

Replies To: Jquery .load Problem

#2 joezim007   User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 110
  • Joined: 13-September 08

Re: Jquery .load Problem

Posted 07 March 2009 - 12:52 PM

Could you post the javascript/jquery code that you're using?
Was This Post Helpful? 0
  • +
  • -

#3 bucko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-June 08

Re: Jquery .load Problem

Posted 19 March 2009 - 06:06 PM

View Postjoezim007, on 7 Mar, 2009 - 11:52 AM, said:

Could you post the javascript/jquery code that you're using?


I have it solved. This is form code.
		<?php $loadpath = "$('#mini_cart').load('index.php?controller=addtocart&amp;action=add&amp;";
			$form_data = "'+GetData()";
		?>
		<input class="button" type="button" id="Add_Product" value="<?php echo $Add_to_Cart; ?>" onclick="<?php echo $loadpath; ?>'+GetData()),document.getElementById('Add_Product').value='<?php echo $Added_to_Cart;?>';">


This is javascript.
<script type="text/javascript">
		function GetData(){
			var item = String("item=" + document.getElementById('product_id').value);
			if(document.forms['product_options'].length != undefined){
				for(i = 0; i < document.forms['product_options'].length; i++){
					if(document.forms['product_options'].elements[i].value){
						if(i == 0){
							item += ":";
						}
						else {
							item += ".";
						}
						item += String(document.forms['product_options'].elements[i].value);
					}
				}
			}			
			var quantity = String("&quantity=" + document.getElementById('quantity').value);
			var data = String(item + quantity);
			return data;
		}
	</script>	


Thanks for your interest.
Was This Post Helpful? 0
  • +
  • -

#4 xerxes333   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Jquery .load Problem

Posted 20 March 2009 - 11:17 AM

Hooray self help!! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1