开发者

Postbacks in PHP

开发者 https://www.devze.com 2023-02-09 20:19 出处:网络
Is there a way to check which link/button was clicked from a form besides using if(isset($_POST[\'myvar\']))

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消