Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing the color of a bootstrap button
Message
De
27/12/2016 12:37:00
 
 
À
27/12/2016 10:27:07
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
PHP
Catégorie:
Autre
Divers
Thread ID:
01646032
Message ID:
01646122
Vues:
27
>>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform