Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing the color of a bootstrap button
Message
From
27/12/2016 12:37:00
 
 
To
27/12/2016 10:27:07
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
PHP
Category:
Other
Miscellaneous
Thread ID:
01646032
Message ID:
01646122
Views:
26
>>>All it takes is an if condition. The problem is there are so many ways of doing this in PHP now. Do you in bead PHP code in the html (the old way) or are you doing this in PHP classes?
>>>
>>>
>>>// in html 
>>><input type="button" class="<?php  (some condition) ? 'class1' : 'class2' ?>" value="button name" />
>>>
>>>
>>>Post some code If that doesn't work for you.
>>
>>Thank you, Jim
>>Yes, I'm embedding the PHP code.
>>I'll look into classes
>
>If you mean to change style properties of objects at runtime, then jQuery is your friend. Check the .addClass(), .removeClass() (or equivalents thereof, it's been eight years since I was seriously playing with that). And the nice thing about jQuery is the selectors - you pretty much always work with a collection of objects fitting your selector, and you don't care how many of them are found (zero, one, many - just like in caveman's maths), you are still making one function call.

Thank you, Dragan.

I'll have to look at Jquery as I do more php work.

Meanwhile, the solution below will never win any awards, but it works.
  <!-- // Change button type depending on picked up status -->
    <?php if( $row['pickedup'] !== "Y"): ?>
  <button type="submit"   class="btn btn-primary"  name="storecode"   
    value="<?=$row['storecode']?>">Go to Store</button>
       <?php else: ?>
          	<button type="submit"   class="btn btn-warning"  name="storecode"
		value="<?=$row['storecode']?>">Go to Store</button>
         <?php endif; ?>
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Reply
Map
View

Click here to load this message in the networking platform