Munna Kumar
Munna Kumar

Reputation: 17

Disable button using php, Not working

Can anyone suggest something I am using osclass opensource. I don't know why conditions not working.

<button type="button" class="button-ii" <?php if(osc_item_formated_price()=="Only Information Available" || $email == "OFF")  {?> disabled="true" <?php } ?><?php>data-toggle="modal"disabled data-target="#myModal">Enquiry</button>

Upvotes: 0

Views: 351

Answers (2)

A.D.
A.D.

Reputation: 2372

Because you doing a wrong practice with PHP code you have an Extra <?php within button try this code may this help you either.

<button type="button" class="button-ii" 
<?php if(osc_item_formated_price()=="Only Information Available" || $email == "OFF")  
{?> disabled="true" <?php } ?> >data-toggle="modal"disabled data-target="#myModal">Enquiry</button>

Upvotes: 1

Mae Cana
Mae Cana

Reputation: 43

Try doing it with different approach,

<?php if(osc_item_formated_price()=="Only Information Available" || $email == "OFF") { ?>
    <button type="button" class="button-ii" disabled>Enquiry</button>
<?php } else { ?>
    <button type="button" class="button-ii" data-toggle="modal" data-target="#myModal">Enquiry</button>
<?php } ?>

OR

<?php if(osc_item_formated_price()=="Only Information Available" || $email == "OFF") { 
    echo '<button type="button" class="button-ii" disabled>Enquiry</button>';
} else {
    echo '<button type="button" class="button-ii" data-toggle="modal" data-target="#myModal">Enquiry</button>';
}

EDIT: I also want to point out that you need to change disable=true to disabled.

And this line data-toggle="modal"disabled does not make sense, remove disabled after data-toggle="modal".

You also have an extra php opening tag here <?php>data-toggle="modal"disabled without a closing. You should remove that refer to the code above.

Upvotes: 0

Related Questions