Solved

Undefined Value in Mozilla

Posted on 2008-11-02
4
318 Views
Last Modified: 2012-06-22
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?
0
Comment
Question by:slegy
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 500 total points
ID: 22863642
Try:

qtysave = document.getElementById('quantity1').value;

instead of:

qtysave=quantity1.value;
0
 

Author Comment

by:slegy
ID: 22863875
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?
0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 22863943
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

0
 

Author Closing Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question