Postbacks in PHP
Is there a way to check which link/button was clicked from a form besides using
if(isset($_POST['myvar']))
{
//if true do this
}
else
{//do this}
or a querystring?
My page has a jquery drop down and thus the above isset function is not working as the form for login is contained in the drop开发者_如何学编程down.
I'm not too familiar with PHP, but going the jQuery route, you can create a hidden field
<input type="hidden" name="postSource" id="postSource" />
and then wire up some event handlers to modify that value before the page is posted.
$('#myControl1, #myControl2').change(function()
{
$('#postSource').val($(this).attr('id'))
});
.NET uses a similar technique, I think. Then on server side, you just access the posted value of the 'postSource' field.
精彩评论