Web Analytics Made Easy -
StatCounter what's wrong with function? - CodingForum

Announcement

Collapse
No announcement yet.

what's wrong with function?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • what's wrong with function?

    Code:
    function verifyFees(){
    			if ( eval(document.thisForm.TotalApprovedSSS.value) + eval(document.thisForm.TotalApproved.value) != eval(document.thisForm.ETotalCost.value) && document.thisForm.MYACTION.options[selected]="YES" ) {
    			document.getElementById("Continue").disabled = true;
    			alert("test");
    			}
    Object expected... all I get =)
    Where is mistake?

  • #2
    several mistakes

    1. eval() is a rather dangerous method to transfor a variable or a result of a calculation in functions into numbers. Simply use Number(string) to transfor a string into a number. Or multiply the string with 1: string*1;

    2 to get the value of the selceted otion you may simply use
    document.thisForm.MYACTION.value
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      Even If I change what you said still get Object expected though.

      Comment


      • #4
        close the function

        function myFunction(){
        if(condition){
        ...some statements
        }
        }
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          Btw, it works fine if i don't have this:
          document.GetElementByID("myaction").value="yes"

          Comment


          • #6
            And it is close... I just didnt post all of it, here is what I have:
            Code:
            function verifyFees(){
            			if ( eval(document.thisForm.TotalApprovedPDC.value) + eval(document.thisForm.TotalApproved.value) != eval(document.thisForm.ETotalCost.value) && document.GetElementByID("myaction").value="yes" ) {
            			document.getElementById("Continue").disabled = true;
            			alert("blabla");
            			}
            		}

            Comment


            • #7
              If it works fine without that line you're missing an element with an id of myaction. It looks like that part is wrong anyway.
              Code:
              document.GetElementByID("myaction").value="yes"
              should be
              Code:
              document.GetElementByID("myaction").value=="yes"
              unless you're intentionally trying to assign "yes" to myaction's value.
              ScriptingMagic.com

              Comment


              • #8
                I don't mean to barge in but, javascript is case sensative:
                document.getElementByID("myaction").value="yes"
                -Brando
                Why using tables for eating is stupid!

                Comment


                • #9
                  Originally posted by Mongus
                  If it works fine without that line you're missing an element with an id of myaction. It looks like that part is wrong anyway.
                  Code:
                  document.GetElementByID("myaction").value="yes"
                  should be
                  Code:
                  document.GetElementByID("myaction").value=="yes"
                  unless you're intentionally trying to assign "yes" to myaction's value.
                  Thank you,
                  that whas the problem (==)

                  Comment


                  • #10
                    I didn't notice before but you're trying to call GetElementByID which isn't a function. You should be calling getElementById. Note the case difference. JavaScript is case sensitive.
                    ScriptingMagic.com

                    Comment

                    Working...
                    X