1

Ok Here's my problem.
I made a form where you can enter multiple items and quantities - You can add additional form fields if you need to add more items.

The form can be accessed at : https://store.jerrysnuthouse.com/wholesaleform

For my shopping cart to recognize multiple items submitted it needs to be submitted as

http://store.jerrysnuthouse.com/cgi-bin/UCEditor?MerchantID=2101&ADD_ITEM=Quantity

Where Item is replaced by the number that the customer inputs and quantity is replaced also.

Right now i have two fields, item and quantity. When submitted they are sent as

http://store.jerrysnuthouse.com/cgi-bin/UCEditor?MerchantID=2101&ADD_Item="ITEM"&quanity="Quantity"

The extra equals signs can't be there.

So couple possible solutions - need to strip the equal signs OR

Need to have the values entered for each item and quantity joined - and submitted somehow to follow the format i've outlined.

Thought about creating another hidden input and joining them there... but then i would need to just submit that one input to my shopping cart

Any thoughts are much appreciated.

BTW - can use jquery or velocity.

Thanks, Nick

<!------Wholesale Form ------->


#ucTemplate("jnh_header_v2")


<head>

<script type="text/javascript">
$(function() {
var addDiv = $('#addinput');
var i = $('#addinput p').size();

$('#addNew').live('click', function() {
$('<p '+ i +'>Item#<input type="text" id="item" size="" name="ADD_" value="" placeholder="I am New item" />Quantity#<input type="text" id="quantity" name=""  value="" placeholder="I am New quantity" /><a href="#" id="remNew">Remove</a> Or <a href="#" id="addNew">Add</a> </p>').appendTo(addDiv);
i++;

return false;
});

$('#remNew').live('click', function() {
if( i > 2 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
});
</script>

</head>




 #set($itemFormSubmitUrl = "http://store.jerrysnuthouse.com/cgi-bin/UCEditor?")
                            <form action="$itemFormSubmitUrl" method="get" id="wholesale_form">
  <input type="hidden" name="MerchantID" value="${merchantID}">
<div id="addinput">
<p>
Item#<input type="text" id="item" size="20" name="ADD_" value="" placeholder="Item #" />  Quantity:<input type="text" id="quantity" size="20" name="" value="" placeholder="Quantity" /><a href="#" id="addNew">Add</a>
</p>
</div>



<div id="addtocart" style="float:left;"><input type="submit" value="add to cart"/></div>
</form>



</div>
Nick Julia
  • 11
  • 2

2 Answers2

0

It seems like there are several things that need to be fixed.

Maybe the line in the click handler for #addNew should look like this:

$('<p '+ i +'>Item#<input type="text" name="ADD_ITEM" value="Quantity" placeholder="I am New item" />Quantity#<input type="text" placeholder="I am New quantity" /><a href="#" id="remNew">Remove</a> Or <a href="#" id="addNew">Add</a> </p>').appendTo(addDiv);

Keep in mind that it is invalid to have multiple elements with the same id attribute and this can cause problems. You may want to use a class instead. See my other question.

Also, what are you trying to do with the part that says '<p '+ i +'>...'? That will output a something like <p 1> or <p 2>. I don't think it makes sense to have numbers as attribute names like that.

Community
  • 1
  • 1
Elias Zamaria
  • 96,623
  • 33
  • 114
  • 148
  • Thanks for the answer @mikez302 Yeah the code isn't pretty. I'm a bit inexperienced with scripting. Found the code for adding additional form fields and adapted it to my purposes. Basically wanted to have a form letting my customer add in item number and quantity - allowing them to input as many as they wanted to by adding more fields if necessary. Any edits or ways to clean it up would be great. Thanks again! – Nick Julia Apr 10 '13 at 16:58
  • As for your other question - yes you're right they shouldn't have the same id. probably should change it to a class or give unique ids. still playing with the form and haven't cleaned up the code yet. Including the inline css etc... – Nick Julia Apr 10 '13 at 17:08
0

I assume that you have to redirect to the above url. In that case you can form the url as a string in javascript and assign the value to location.href

location.href = 'http://store.jerrysnuthouse.com/cgi-bin/UCEditor?MerchantID=2101&ADD_ITEM=Quantity';

This will submit the data and redirect to the page.

ManojRK
  • 952
  • 9
  • 22