Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Echo Variable Javascript

Posted on 2013-12-06
3
Medium Priority
?
361 Views
Last Modified: 2013-12-06
The following code I'm having some issues with.  I need to echo the variable "qtycheck" to see if it's getting populated correct as I suspect that's the issue.

How can I echo it out on the page to see?

<script type="text/javascript">
    function check() {
        var elements = document.getElementsByName("quantity");
        var qtycheck = document.getElementById("qtycheck").value;
        for (var i=0; i<elements.length; i++) {
            var nmbr = elements[i].value;
            if (nmbr > <?php echo $maxqtyorder; ?>){
                alert("You've selected more treats than your package allows.");
                return false;
            }
            else if (nmbr > qtycheck){
                alert("You've selected more treats than your package allows.");
                return false;
            }
        }
        return true;
    }
</script>

Open in new window

0
Comment
Question by:Nathan Riley
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 2000 total points
ID: 39701466
Pop it to a dialog box

alert(qtycheck);

Open in new window


You could also use
document.write(qtycheck);

Open in new window

0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 39701472
@Isavidge

Where in my code would I input that?
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 39701481
Nevermind, got it thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 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