Results 1 to 7 of 7

Thread: determine calling form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Unhappy

    I want to have 2 forms that submit to the same ASP document (one is for adding records and one is for modifying). I want to do this because MOST but not ALL of the code will be the same for both adding and modifying a record, but I don't know how to determine which form called the ASP form.

    How can I determine which form called the ASP form? In other words, in the Modify form I have the code

    <form action="DailyReportConfirmation.asp" method="post" id="frmSubmit">

    How can I determine that the MODIFY form and not the ADD form called the ASP page?

    Thanks

    Andrew

  2. #2
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118

    Lightbulb

    One way of doing is add a hidden input box [MODE] in both the forms and set values in MODE input box to ADD and UPDATE respectively. Then in DailyReportConfirmation.asp check for the value in MODE input box, the determines the MODE u r in..

    Sonia

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    Cool. I am just about to dive into learing about hidden items, so I will try that. Thanks

  4. #4
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    i'm a little confused

    if you have two seperate forms then you will have two seperate Submit buttons and two seperate Actions.
    but those two forms can't share the same input box's so maybe this isn't what you want.


    if you have two forms you don't have to determin what form called the new.asp page. the form does that for you

    for clarification...
    you have (say) 4 text fields on your page named
    text1, text2, text3, and text 4 but when the user submits you may only want the data from text1 and text3 to go to the NewPage.asp page?
    is this correct?


    or maybe a better way is to use only the data you need on page two.

    info1 = request.("text1")
    info2 = request.("text2") ect...

    then only use the info variables you need on page two..
    pnj

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    Hi pnj and company -

    I set a MODE flag like harsoni suggested and it worked fine. But now pnj tells me
    if you have two forms you don't have to determin what form called the new.asp page. the form does that for you
    Okay, that is good. But how do I determine in code which one it was? Is there some property? I need to do something like
    Code:
    If CallingForm = Form1 Then
         cn.Execute (INSERT...
    ElseIf CallingForm = Form2 Then
         cn.Execute(UPDATE...
    End If

  6. #6
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    this may end up confusing both of us......:)

    if you have two forms you would have something like this

    <form name=frmONE action=newpage.asp method=post>
    <input type=text name=oneFirstName>
    <input type=text name=oneLastName>
    <input type=submit value=submit>
    </form>

    <form name=frmTWO action=newpage.asp method=post>
    <input type=text name=FirstName>
    <input type=text name=LastName>
    <input type=submit value=submit>
    </form>

    when you hit the input box, only the data from that form will be sent to newpage.asp so if
    frmONE submit is clicked only oneText and oneText2 values will be sent to the newpage.asp page.

    you can see i have named the examples the same except for the form NAME. If you only want
    one form on your page you can determine what the action will be on newpage.asp by passing in the
    querystring something like this
    newpage.asp?action=delete
    newpage.asp?action=update
    newpage.asp?action=whatever you want to do.......


    you can do something like this on newpage.asp

    dim action
    action=request.querystring("action")

    if action = "delete" then
    cn.Execute("delete....
    elseif action ="update" then
    cn.UPdate("update....
    end if


    ect.....



    you can also use javascript on page one to change the ACTION of the form.

    so instead of having one submit button. you have two buttons like this
    <input type=button onClick="javascript:yourFunction();">

    and your funcion could look something like this:

    <script>
    function yourFunction()
    {
    document.frmONE.action=newpage.asp?action=delete
    document.frmONE.submit();
    }
    </script>

    make sense?
    if the way you are doing it works though, go with it......
    pnj

  7. #7
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    drewdog.
    i don't know if i explained what i ment to in that last post

    try this...
    create the two forms on page one.make them simple(two text box's) name both forms w/ different names but make the text fields have the same name (maybe text1, text2)
    then on page two try and acces the values of those forms by maybe doing something like this

    <%=request.form("text1")%>
    <%=request.form("text2")%>

    before you submit the form on page one type in different values for each text box.
    you will only see the values on page two from what ever page you sent....
    make sense?

    harsoni s way is a cool way to determine what form was sent so if that works stick w/ it.....
    i was just trying to spread some more light on the forms subject
    pnj

Posting Permissions

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



Click Here to Expand Forum to Full Width