multi-action Forms

Discussion in 'Software' started by wildchild, Jun 25, 2005.

  1. wildchild

    wildchild Private E-2

    hey, im having a little problem and just wondering if anyone here could help me?

    i have a form with ACTION="del.asp", and a input type="submit" however i would like a second button that will send the variables to a different file, named edit.asp, but i have no idea how to do this...

    thanks
     
  2. rpgfan3233

    rpgfan3233 Private E-2

    Perhaps this can get you started:
    http://www.chami.com/tips/internet/042599I.html

    Basically, give both submit buttons the same name but with different values:
    Code:
    <input type="submit" name="bsubmit" value="edit">
     <input type="submit" name="bsubmit" value="delete">
    Use an ASP page to choose which page to go to based on the value of "bsubmit" (in the example).

    I hope this at least gets you started.
     
  3. wildchild

    wildchild Private E-2

    thanks for the help, i've managed to build that (i use javascript ASP though) however its always doing the first option, no matter what value is sent

    Code:
    <%@language="javascript"%>
    <HEAD>
    <%
    var conn=Server.CreateObject("ADODB.Connection");
    conn.Provider="Microsoft.Jet.OLEDB.4.0";
    db = Server.MapPath("db.mdb");
    conn.Open(db);
    
    var val=Request.Form("submit")
    var item=Request.Form("itemdel")
    
    if (val="Edit") {
    Response.Write("coming soon")
      }
     else {
    if (val="Delete") {
    Response.Write("Item Deleted, Please wait while you are redirected back to the Admin Control Panel");
    sql = "DELETE FROM Affiliates WHERE AffiliateNumber = "+unescape(item);
    conn.Execute(sql);
      }
     }
    %>
    </HEAD>
    
    but its saying "coming soon" no matter which button is pressed :rolleyes: :( :eek:
     
  4. rpgfan3233

    rpgfan3233 Private E-2

    That's probably because in JavaScript, you have to use '==' rather than '=' when comparing things. Try this:

    Code:
    <%@language=&quot;javascript&quot;%>
     <HEAD>
       <%
       var conn=Server.CreateObject("ADODB.Connection");
       conn.Provider="Microsoft.Jet.OLEDB.4.0";
       db = Server.MapPath("db.mdb");
       conn.Open(db);
       
       var val=Request.Form("submit")
       var item=Request.Form("itemdel")
       
       if (val == "Edit") {
       Response.Write("coming soon")
         }
      else if (val == "Delete") {
       Response.Write("Item Deleted, Please wait while you are redirected back to the Admin Control Panel");
       sql = "DELETE FROM Affiliates WHERE AffiliateNumber = "+unescape(item);
       conn.Execute(sql);
         }
       %>
      </HEAD>
     
  5. wildchild

    wildchild Private E-2

    ah i feel so stupid now :(

    thanks though its all working now


    do you have MSN?
     
  6. rpgfan3233

    rpgfan3233 Private E-2

    Nope. :D I have AIM though. If you use AIM, I can send my screenname/username in a PM.
     
  7. Kodo

    Kodo SNATCHSQUATCH

    the best way to do this is to do something like


    <form method="post" action="">

    stuff here


    <input type="text" value="submit-delete" onclick="this.form.action='delpage.asp'"; >
    <input type="text" value="submit-delete" onclick="this.form.action='otherpage.asp'"; >
    </form>
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds