views:

735

answers:

1

This is what is being passed (as seen by PHP), which is a little jacked up:

[action] => AddDailyDeal
[addDailyDealFormProductTitle] => Gatorade 20 oz. bottle
[addDailyDealFormPrice] => 1.23
[addDailyDealFormShippingCost] => 4.56
[addDailyDealFormDealURL] => http://www.dealurtl.com
[addDailyDealFormTrackingImageURL] => http://www.trackingimage.com
[addDailyDealFormProductDescription] => lkhg khjgkhjg
[dealImageUpload0] => Photo 3.jpg
[addDailyDealFormAdditionalInfoItemTitle] => Array
    (
        [0] => 1
    )

[parentID] => 1
[addDailyDealFormAdditionalInfoItemValue] => Array
    (
        [0] => Array
            (
                [0] => manufacturer 90 day
            )

        [[object Object] => 
    )

[addDailyDealFormAdditionalInfoItemTitle1] => 2
[submit] => Add this Deal

The issue here is that there were two addDailyDealFormAdditionalInfoItemTitle entered, and the passed data should look like this (based off what was entered in the form:

[action] => AddDailyDeal
[addDailyDealFormProductTitle] => Gatorade 20 oz. bottle
[addDailyDealFormPrice] => 1.23
[addDailyDealFormShippingCost] => 4.56
[addDailyDealFormDealURL] => http://www.dealurtl.com
[addDailyDealFormTrackingImageURL] => http://www.trackingimage.com
[addDailyDealFormProductDescription] => lkhg khjgkhjg
[dealImageUpload0] => Photo 3.jpg
[addDailyDealFormAdditionalInfoItemTitle] => Array
    (
        [0] => 1
        [1] => 5
    )

[parentID] => 1
[addDailyDealFormAdditionalInfoItemValue] => Array
    (
        [0] => Array
            (
                [0] => 90 watta
                [1] => other things
                [2] => smells funny
            )

        [1] => Array 
            (
                [0] => manufacturer 90 day
            )
    )
[submit] => Add this Deal

Here is the HTML / JS

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
 <script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
 <script>
  google.load("jquery", "1.3.2");
  google.load("jqueryui", "1.7.2");
 </script>
</head>
<body>
<div id="wrapper">
 <div id="content">
<script type="text/javascript">
        $(document).ready(function() {
                $('.btnAddTitle').live('click', function() {
                        var LastAdditionalInfoItemTitle = $('.clonedInput:last');
                        var num = LastAdditionalInfoItemTitle.attr("id").replace("AdditionalInfoItemTitle", "");
                        var newNum = new Number(num) + 1;
                        var newElem = LastAdditionalInfoItemTitle.clone().attr('id', 'AdditionalInfoItemTitle' + newNum);
                        newElem.children('select:first').attr('id', 'addDailyDealFormAdditionalInfoItemTitle[' + newNum + ']').attr('name', 'addDailyDealFormAdditionalInfoItemTitle' + newNum);
                        newElem.children('div.clonedInputValue').children('input.parentID').val(newNum);
                        LastAdditionalInfoItemTitle.after(newElem);
                });
                $('.btnAddValue').live('click', function() {
                        var LastAdditionalInfoItemValue = $(this).parent().parent().children('.clonedInputValue:last');
                        var num = LastAdditionalInfoItemValue.attr("id").replace("AdditionalInfoItemValue", "");
                        var newNum = new Number(num) + 1;
                        var newElem = LastAdditionalInfoItemValue.clone().attr('id', 'AdditionalInfoItemValue' + newNum);
                        newElem.children('textarea:first').attr('name', 'addDailyDealFormAdditionalInfoItemValue[' + $(this).siblings(".parentID") + '][' + newNum + ']');
                        LastAdditionalInfoItemValue.after(newElem);
                });
                $('.btnAddImage').live('click', function() {
                        var num     = $('.clonedImage').length - 1;
                        var newNum  = new Number(num + 1);
                        var newElem = $('#DealImage' + num).clone().attr('id', 'DealImage' + newNum);
                        newElem.children(':first').attr('id', 'dealImageUpload' + newNum).attr('dealImageUpload', 'dealImageUpload' + newNum);
                        $('#DealImage' + num).after(newElem);
                });
        });
</script>
<form method="post" action="index.php" name="addNewDailyDeal">
<input type="hidden" name="action" value="AddDailyDeal" />
 <dl id="dailyDealForm">
  <dt>Product Title</dt>

  <dd><input type="text" name="addDailyDealFormProductTitle" /></dd>
  <dt>Price</dt>
  <dd><input type="text" name="addDailyDealFormPrice" /></dd>
  <dt>Shipping Cost</dt>
  <dd><input type="text" name="addDailyDealFormShippingCost" /></dd>
  <dt>Deal URL</dt>
  <dd><input type="text" name="addDailyDealFormDealURL" /></dd>

  <dt>Tracking Image URL</dt>
  <dd><input type="text" name="addDailyDealFormTrackingImageURL" /></dd>
  <dt>Product Description</dt>
  <dd><textarea name="addDailyDealFormProductDescription" cols="40" rows="5"></textarea></dd>
 </dl>
 <h3>Deal Images</h3>
 <div id="DealImage0" class="clonedImage">

  <input type="file" name="dealImageUpload0"> 
  <input type="button" class="btnAddImage" value="+" />
 </div>
 <h3>Additional Info Items</h3>
 <div id="AdditionalInfoItemTitle0" class="clonedInput">
  <select name="addDailyDealFormAdditionalInfoItemTitle[0]">
   <option value="1">Features</option>
   <option value="2">Warranty</option>

   <option value="3">Specifications</option>
   <option value="4">In the box</option>
   <option value="5">Dimensions</option>
   <option value="6">Connections</option>
   <option value="7">Interfaces</option>
  </select>

  <input type="button" class="btnAddTitle" value="+" />
  <div id="AdditionalInfoItemValue0" class="clonedInputValue">
   <input type="hidden" class="parentID" name="parentID" value="0" />
   <textarea name="addDailyDealFormAdditionalInfoItemValue[0][0]" rows="2" cols="30"></textarea>
   <input type="button" class="btnAddValue" value="+" />
  </div>
 </div>
<input type="submit" name="submit" value="Add this Deal" />
</form>
 </div>
 </div>
</body></html>
A: 

Patrick, this is way to much code to read. Try to be short and concise, then helpful answers will be more likely.

Cheers, Tom

Tom Bartel