Jump to content

[SOLVED] Need Form Help


NoSalt

Recommended Posts

Hello All

 

    I have what I thought was a very simple html form design; but, as it turns out, doesn't work. Here is what I have:

 

    <form name="deleteEvent" method="POST" action="./eventHandler.php">
        <ul>
            <li><button type="submit" id="10">X</button>event ten</li><input type="hidden" name="eventID" value="10">
            <li><button type="submit" id="36">X</button>event thirty six</li><input type="hidden" name="eventID" value="36">
            <li><button type="submit" id="55">X</button>event fifty five</li><input type="hidden" name="eventID" value="55">
            <li><button type="submit" id="40">X</button>event forty</li><input type="hidden" name="eventID" value="40">
            <li><button type="submit" id="25">X</button>event twenty five</li><input type="hidden" name="eventID" value="25">
            <li><button type="submit" id="13">X</button>event thirteen</li><input type="hidden" name="eventID" value="13">
        <ul>
        <input type="hidden" name="deleteEvent" value="1">
    <form>

 

Every time I click on the delete button, the POST value that gets passed is always the very last id in the list; in this case the POST value passed will be "13", even if I click the delete button for "event ten", "event fifty five", "event twenty", etc. No matter which delete button I click, the POST value passed will always be the last one in the list. Can somebody tell me why this doesn't work and possibly how to fix it?

 

Thank you all for reading. Have a good day/night.  :)

Link to comment
Share on other sites

Well ... I figured that I would use the following method to get it to work:

 

    <ul>
        <li><form name="deleteEvent_10" method="POST" action="./eventHandler.php"><button type="submit" id="10">X</button>event ten<input type="hidden" name="eventID" value="10"><input type="hidden" name="deleteEvent" value="1"></form></li>
        <li><form name="deleteEvent_36" method="POST" action="./eventHandler.php"><button type="submit" id="36">X</button>event thirty six<input type="hidden" name="eventID" value="36"><input type="hidden" name="deleteEvent" value="1"></form></li>
        <li><form name="deleteEvent_55" method="POST" action="./eventHandler.php"><button type="submit" id="55">X</button>event fifty five<input type="hidden" name="eventID" value="55"><input type="hidden" name="deleteEvent" value="1"></form></li>
        <li><form name="deleteEvent_40" method="POST" action="./eventHandler.php"><button type="submit" id="40">X</button>event forty<input type="hidden" name="eventID" value="40"><input type="hidden" name="deleteEvent" value="1"></form></li>
        <li><form name="deleteEvent_25" method="POST" action="./eventHandler.php"><button type="submit" id="25">X</button>event twenty five<input type="hidden" name="eventID" value="25"><input type="hidden" name="deleteEvent" value="1"></form></li>
        <li><form name="deleteEvent_13" method="POST" action="./eventHandler.php"><button type="submit" id="13">X</button>event thirteen<input type="hidden" name="eventID" value="13"><input type="hidden" name="deleteEvent" value="1"></form></li>
    <ul>

 

It may not be pretty or the best method - or it could be for all I know - but it works perfectly, just like I wanted.

 

Have a good one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.