简体   繁体   中英

How to change a button's name

this code out put is here ....(look at the footer subscribe section )

<?php if(!empty($this->items))foreach($this->items as $level): ?>
<?php
    $formatedPrice = sprintf('%1.02f',$level->price);
    $dotpos = strpos($formatedPrice, '.');
    $price_integer = substr($formatedPrice,0,$dotpos);
    $price_fractional = substr($formatedPrice,$dotpos+1);
?>
    <div class="level akeebasubs-level-<?php echo $level->akeebasubs_level_id ?>">
        <p class="level-title">
            <span class="level-price">
                <?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'before'): ?>
                <span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span>
                <?php endif; ?>
                <span class="level-price-integer"><?php echo $price_integer ?></span><?php if((int)$price_fractional > 0): ?><span class="level-price-separator">.</span><span class="level-price-decimal"><?php echo $price_fractional ?></span><?php endif; ?>
                <?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'after'): ?>
                <span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span>
                <?php endif; ?>
            </span>
            <span class="level-title-text">
                <a href="<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>">
                    <?php echo $this->escape($level->title)?>
                </a>
            </span>
        </p>
        <div class="level-inner">
            <div class="level-description">
                <div class="level-description-inner">
                    <?php if(!empty($level->image)):?>
                    <img class="level-image" src="<?php echo JURI::base()?><?php echo trim(AkeebasubsHelperCparams::getParam('imagedir','images/'),'/') ?>/<?php echo $level->image?>" />
                    <?php endif;?>
                    <?php echo JHTML::_('content.prepare', AkeebasubsHelperMessage::processLanguage($level->description));?>
                </div>
            </div>
            <div class="level-clear"></div>
            <div >
                <button  onclick="window.location='<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>'">
                    <?php echo JText::_('COM_AKEEBASUBS_LEVELS_SUBSCRIBE')?>
                </button>
            </div>
        </div>
    </div>
<?php endforeach; ?>

this is the language file contain that name

COM_AKEEBASUBS_LEVELS_SUBSCRIBE="Subscribe Now"

I want to name those three sections butons as 6month,12month,24month

How will change the code ?

If you are unable to get the value using PHP, try changing the value of the button's name on page load Here is the JQUERY

 $(document).ready(function){
   $('div.akeebasubs-awesome-description').each(function(
     substription =  $(this).children('H4').html()
     button = $(this).parent().next().children('button')
     $(button).attr(name,substription.split(' ')[0]+'month')
    })
 })

and the JAVASCRIPT

 divs = document.getElementsByClassName('akeebasubs-awesome-description');
 for (var i in divs){
    divs[i].parentElement.nextElementSibling.children[0].name = divs[i].children[0].innerHTML.split(' ')[0] + 'month'
 }

This will take the text of the H4 and make that the corresponding button 's name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM