I’m trying to do a simple thing of changing the value of a submit button based on an input box being checked but the value wont change from edit to save.
Any ideas?
function checkScheme(el) {
$('[name=schemebutton]').val('Save');
}
<input type="submit" name="schemebutton" value="Edit" style="float:right;" />
Post the code where you invoke checkScheme() function.
<script type="text/javascript">
function checkScheme(el) {
$('[name=schemebutton]').val('Save');
var val = el.value;
switch (val) {
case "0":
$('schemeextras').hide();
break;
case "1":
$('schemecompanylabel').show();
$('schemecompanyvalue').show();
$('schemeextras').show();
break;
case "2":
$('schemecompanylabel').hide();
$('schemecompanyvalue').hide();
$('schemeextras').show();
break;
}
}
</script>
<div id="scotlandscheme" class="profilepageblock profilepageblockborder"{if !$scotland} style="display: none;"{/if}>
<form action="profile.php" method="post" id="schemeForm">
<input type="hidden" name="action" value="saveScheme" />
<h3>Disclosure Scotland</h3>
<div class="notification" id="user_scheme_warning"> </div>
<div class="profilepageblockcontent">
<p>As a pharmacist working in a locum capacity with Boots for the first time, by law, and in line with the Disclosure Scotland guidelines, you are required to have a Scheme Record.</p>
<p>If you have a SR (Scheme Record) or SMS (Scheme Membership Statement) you will be required to take that with you on your first placement. An SR (Scheme Record) will be required for on-going bookings.</p>
<div class="profilepageblockcontentblue">
<div class="profilepageblockcontentbluecontent">
<p style="margin-bottom:4px;">Do you have either of the following:</p>
<p style="margin-bottom:4px;"><input type="radio" name="radio_user_scotlandscheme" onclick="checkScheme(this)" id="user_scotlandscheme1" {if $user->user_scotlandscheme eq "1"}checked="checked"{/if} value="1" /><label for="user_scotlandscheme1">Scheme Record - with another healthcare organisation (Pharmacy/Opticians/Hospital)</label>
<p style="margin-bottom:4px;"><input type="radio" name="radio_user_scotlandscheme" onclick="checkScheme(this)" id="user_scotlandscheme2" {if $user->user_scotlandscheme eq "2"}checked="checked"{/if} value="2" /><label for="user_scotlandscheme2">Scheme Membership Statement</label>
<p style="margin-bottom:4px;"><input type="radio" name="radio_user_scotlandscheme" onclick="checkScheme(this)" id="user_scotlandscheme0" {if $user->user_scotlandscheme eq "0"}checked="checked"{/if} value="0" /><label for="user_scotlandscheme0">I have neither.</label>
</div>
<div class="profilepageblockcontentbluebottom"><!-- ie --></div>
</div>
<div id="schemeextras" class="profilepageblockcontentblue"{if $user->user_scotlandscheme eq "0"} style="display: none;"{/if}>
<div class="profilepageblockcontentbluecontent">
<div class="formLabel"><label for="user_schemereference">Scheme Record - Reference No</label></div>
<div class="formFieldArea2"><input type="text" id="user_schemereference" name="user_schemereference" value="{$user->user_schemereference}" /></div>
<div class="formLabel" id="schemecompanylabel"><label for="user_schemecompany">Company Name</label></div>
<div class="formFieldArea2" id="schemecompanyvalue"><input type="text" id="user_schemecompany" name="user_schemecompany" value="{$user->user_schemecompany}" /></div>
<div class="formLabel"><label for="user_schemedate">Date</label></div>
<div class="formFieldArea2" >
<input type="text" style="width: 20px;" size="2" value="{$user->user_schemedate_day}" id="user_schemedate_day" name="user_schemedate_day">(DD)
<input type="text" style="width: 20px;" size="2" value="{$user->user_schemedate_month}" id="user_schemedate_month" name="user_schemedate_month">(MM)
<input type="text" style="width: 40px;" size="4" value="{$user->user_schemedate_year}" id="user_schemedate_year" name="user_schemedate_year">(YYYY)
</div>
<div class="formFieldArea" style="border:0px solid red; width:100%;" ><input type="submit" name="schemebutton" value="Edit" style="float:right;" /></div>
</div>
<div class="profilepageblockcontentbluebottom"><!-- ie --></div>
</div>
</div>
</form>