Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts

    function calling a function issue

    Here are my functions:
    Code:
    function submit_order( form ) {
                            if (!form.agreed.checked) {
                                alert( \"". $VM_LANG->_PHPSHOP_AGREE_TO_TOS ."\" );
                                return false;
                            }
                            else {
                                check_cb2(this.form);
                            }
                        }
                        		
                        function check_cb2( form ) {
                            if (!form.bkwarn.checked) {
                                alert( \"". $VM_LANG->_PHPSHOP_BK_WARN_CHECK ."\" );
                                return false;
                            }
                            else {
                                return true;
                            }
                        }
    Here is where it is getting called:
    Code:
    <input type="submit" onclick="return( submit_order( this.form ) );" class="button_2" name="submit" value="<?php echo $VM_LANG->_PHPSHOP_ORDER_CONFIRM_MNU ?>" />
    It is just checking to make sure two checkboxes are checked before the form can be submitted.

    If checkbox "agreed" is not checked it will pop up my alert. If I check it the form will submit regardless of whether or not "bkwarn" is checked.

    Any ideas?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    else {
        check_cb2(this.form);
        return true;
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv View Post
    Code:
    else {
        check_cb2(this.form);
        return true;
    }
    Thanks for the reply.

    Unfortunately that works the same way as before. The only checkbox that needs to be checked is "agreed" before the form submits.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Then don't call check_cb2 function in the "else" block if you don't want to validate "bkwarn" when "agreed" is checked.

    When do you really want to validate "bkwarn"?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I want both to be validated before the form is submitted.

    I should rephrase "The only checkbox that needs to be checked is "agreed" before the form submits" to say that it is only requiring "agreed" to be checked now, but I need them both to be checked.

    What I was trying to do was check if agreed is checked. If not, return the alert. If it is checked, see if bkwarn is checked. If not, return the alert. If it is checked, submit the form.

    There is probably a better way to do this, this was just the first thing that came to mind. It was originally just checking "agreed" as it was the only checkbox, I have had to add an extra checkbox so I was just trying to add on to the existing javascript.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    If you need both to be validated, then just return the value of check_cb2.
    Code:
    function submit_order( form ) {
        if (!form.agreed.checked) {
           alert(". $VM_LANG->_PHPSHOP_AGREE_TO_TOS .");
           return false;
        }
        return  check_cb2(this.form);
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New Coder
    Join Date
    Jul 2006
    Location
    Cincinnati, OH
    Posts
    85
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks, that does it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •