Use id attribute for isset in php

Is it possible to use the id attribute in PHP with isset? It happens that I am not allowed to put a name attribute on a button. Thank you

example:

<button id="btnID" class="transaction-form-object">Submit</button>

edit: Sorry if my questions is blurry. It happens that the api that im posting is rejecting the name attribute of a button and input. I am only allowed to use the button w/o a name attribute. If i add the name attribute it will add to the calculation of validations that would result to fail as they have limitations on posting..

2 answers

  • answered 2018-11-08 07:37 Oliver Primo

    Maybe you can use the input element so that you can add a name attribute to it and use it as a post selector.

    example:

    <input type="submit" name="btnID" class="transaction-form-object" value="Submit"/>
    

    then use it in your php as: $_POST['btnID']

    Hope this helps :)

  • answered 2018-11-08 07:48 Sayed Mohd Ali

    yes, you can do it using Ajax.

    <ul id="todo" class="todoclassname" />
    

    hen, you can get the id by doing:

    var id = $(".todoclassname").attr("id");
    

    now use ajax to post id data on php page.

    $.ajax({
            type: 'POST',
            url: 'yourpagename.php',
            data: 'postID='+id,
            dataType: 'json',
            success : function(data) {
    
                }
    
        });