ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

babe in the woods

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

  • babe in the woods

    Im trying to add another if clause into a function. The ";" and the "{" "}"
    are throwing me a bit..... any help would be appreciated.

    my form submit looks like this the onsubmit executes the function onsubmitform which currently only
    validates the a file was selected for uploading. I want to add another validation against a Po#
    that is in a table on the iseries. Im just confused as to the "form".
    PHP Code:
    <form name="frmSend" method="POST" enctype="multipart/form-data" action="uploadTester.asp" onSubmit="return onSubmitForm();"

    the function is:
    PHP Code:
    <script>
    function 
    onSubmitForm() 

    {
        var 
    formDOMObj document.frmSend;
        if (
    formDOMObj.attach1.value == "")
            
    alert("Please press the browse button and pick a file.")
        else
            return 
    true;
        return 
    false;
    }

    </
    script



    and I want to add:
    PHP Code:
    {
    'now validate the PO#'
    sqlstmt "SELECT count(*) as recordfound   FROM " _
      prodlib 
    ".PCHSPCH  WHERE PHPO# = "  Upload.Form("PO#")
      
    response.write(sqlstmt)
      
    set recordfound connection.Execute(sqlstmt)
      if (
    recordfound  == 0
       
    alert("Invalid Purchase Order Entered.")
      return 
    false;} 
    Thanks in advance
    I'm here to chew bubble gum and kick @#%@#%@#%.....and I'm all outta bubble gum !
    Yes I'm talking to you squirrel nuts.

  • #2
    Re: babe in the woods

    Maybe something like this: I haven't tested this and I'm no expert at scripts but this might get you headed in the right direction.

    <php>
    function onSubmitForm()

    {
    var formDOMObj = document.frmSend;

    if (formDOMObj.attach1.value == "")

    {

    alert("Please press the browse button and pick a file.")
    return false;

    } else {

    'now validate the PO#'
    sqlstmt = "SELECT count(*) as recordfound FROM " & _
    prodlib & ".PCHSPCH WHERE PHPO# = " & Upload.Form("PO#")
    response.write(sqlstmt)
    set recordfound = connection.Execute(sqlstmt)

    if (recordfound == 0) {
    alert("Invalid Purchase Order Entered.")
    return false;
    } else {

    return true;
    }
    }
    }

    </php>
    Goodbye

    Comment

    Working...
    X