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
https://forums.phpfreaks.com/topic/7912-firefoxie-submit-button-different-_post/
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.