Link to home
Start Free TrialLog in
Avatar of slegy
slegy

asked on

Undefined Value in Mozilla

We have a small store on our website. When an item is selected values are set in a PayPal form and then submitted to PayPal. I thought I had it working in IE, Safari and Mozilla, but when retesting this afternoon, I find I'm getting an error in Mozilla. Here is an item description:

      <div id="optionalText"></div>
      <div id="itemMain">
        <div id="itemName">White Lightning Flash Cap</div>
        <div id="itemImage"><img src="../../../assets/images/store/hats/lightCap.jpg" alt="White Lightning Flash Cap" width="226" height="151" /></div>
        <div id="itemDescription"><br />
          Unstructured, low profile, six panel, soft mesh, back cap. <br />
          <br />
          Padded sweatband. <br />
          <br />
          Adjustable self-fabric closure with sliding silver buckle. <br />
          <br />
          Color: putty/black.</div>
        <div id="itemAttributes">
          <div id="attribute">
          </div>
        </div>
      </div>
      <div id="order">
        <div id="itemOrder">
          <div id="costShip">
            <div id="price"> <strong>Price:</strong> $20.00 </div>
            <div id="shipping"> <strong>Shipping</strong>: $3.00 </div>
          </div>
          <div id="order">
            <div id="nbrItems">
              <label><strong>Quantity:</strong></span>
              <select name="quantity1" id="quantity1">
                <option value="1" selected="selected">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
              </select>
              </label>
            </div>
            <div id="addtoCart">
              <input name="addCart1" type="submit" id="addCart1" onclick="MM_callJS('ppsubmit(\&quot;lightHat\&quot;)')" value="Add to Cart" />
            </div>
          </div>
        </div>
      </div>
Here is the validation code:

<script type="text/javascript" language="JavaScript">
var amtsave;
var shipsave;
var qtysave;

function ppsubmit(product)
{
      switch(product)
      {
      case "lightHat":
                        amtsave="20.00";
                        shipsave="3.00";
                        qtysave=quantity1.value;
                        document.paypalform.item_name.value="White Lightning Flash Cap";
      if (qtysave == "1")
            {
            document.paypalform.shipping.value=shipsave;
            document.paypalform.quantity.value=qtysave;
            }
            else
            {
             document.paypalform.shipping.value=shipsave*qtysave;
             document.paypalform.quantity.value=qtysave;
            }
            document.paypalform.amount.value=amtsave;
            document.paypalform.submit();
}
Mozilla is issuing an error saying "quantity1" is undefined. Any ideas how it wants a list/menu value defined?
ASKER CERTIFIED SOLUTION
Avatar of LordOfPorts
LordOfPorts
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slegy
slegy

ASKER

It works great - thank you! One last question - this should be simple:

I'm trying to concatenate color, item description and size:
document.paypalform.item_name.value=document.getElementById('color1').value;+" Lightning Polo Shirt";
The "Lightning Polo Shirt" is being ignored. Any idea why?
The semi-colon after .value should be removed, then it should work:
document.paypalform.item_name.value = document.getElementById('color1').value + " Lightning Polo Shirt";

Open in new window

Avatar of slegy

ASKER

Everything is working great! Now we know why the store in the current site has never worked in Mozilla. Thank you so very much.