Jump to content

Firefox/IE Submit Button Different $_POST


peterclutton

Recommended Posts

Hi all, i'd really appreciate any insight or workaround for this.

I have a form that displays a number of records, and at the bottom gives you buttons with various options, eg. Insert, Edit, Delete. These are basically in the form of:

<button type=submit name=insert>Insert</button>


I then have coe that checks the $_POST variable and acts accordingly. In Firefox, it works fine, and when I output print_r($_POST) after clicking Insert, it shows me Array(insert => insert) etc as you would expect.

However in IE when i click one of these buttons, it sets ALL the values. When i display post it shows insert => insert delete => delete and so on. Thus each seperate section of code i have all gets called.

Am i doing this the wrong way? Is there an easy fix, or should i change the approach entirely? Many Thanks in advance!
Link to comment
Share on other sites

You can, instead of using several submit buttons, a radio group like this:

[code]<input type="radio" name="action" value="del"> Delete
<input type="radio" name="action" value="add"> Insert
<input type="radio" name="action" value="edt"> Edit[/code]
So you just check $_GET['action'] or $_POST['action'] and it's done.

If you want to use buttons, you can create a hidden field and use javascript to set it and submit the form:

[code]function del()
{
   act = document.getElementById('act');
   act.value = 'Delete';
   document.forms[0].submit();
}

//////

<input type="button" value="Delete" onclick="del();">
<input type="hidden" name="action" id="act">[/code]
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.