My base code :
<button class="puple margin-right" type="button" onclick="setPasswordForm()" title="<?php echo $this->__('Change Password') ?>" class="button"><span id="change_password_text"><?php echo $this->__('Change Password') ?></span></button>
<script type="text/javascript">
//<![CDATA[
var dataForm = new VarienForm('form-validate', true);
function setPasswordForm(){
var arg = $('change_password').value;
if(arg == 0){
$('current_password').up(3).show();
$('current_password').addClassName('required-entry');
$('password').addClassName('required-entry');
$('confirmation').addClassName('required-entry');
$('change_password').setValue('1');
$('change_password_text').update('<?php echo $this->__('Cancel Change Password') ?>');
}else{
$('current_password').up(3).hide();
$('current_password').removeClassName('required-entry');
$('password').removeClassName('required-entry');
$('confirmation').removeClassName('required-entry');
$('change_password').setValue('0');
$('change_password_text').update('<?php echo $this->__('Change Password') ?>');
}
}
<?php if($this->getCustomer()->getChangePassword()): ?>
setPasswordForm();
<?php endif; ?>
I have a button “change password”, and it will be change to “cancel change password” when a form “change password” have been displayed.
How to add a title for button “Cancel change password”?
Any answer ???
You just need to change these lines
$('change_password_text').update('<?php echo $this->__('Cancel Change Password') ?>');to
$('#change_password_text').text('Cancel Change Password');Same goes for the
elsestatement.Note: you are missing a
#to target thechange_password_textid.