Solved

Undefined Value in Mozilla

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...))The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all current…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
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…

828 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