Solved

Undefined Value in Mozilla

Posted on 2008-11-02
4
314 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
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.

786 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