I just dont know how to change my buttons once clicked. All I want is to change this button
<input type="button" onclick="codename()" id="myButton1" value="New" class="btn" name="New" style="height: 60px; width: 90px">
to this button
<input type="submit" value="Save" class="btn2" name="Query" style="height: 60px; width: 90px">
once clicked.I have used the
button to enable a disabled text forms, and it works. So basically my NEW BUTTON will do 2 things: first is to enable disabled forms and button (working) AND second is to change that same button from
<input type="button" onclick="codename()" id="myButton1" value="New" class="btn" name="New" style="height: 60px; width: 90px">` to `<input type="submit" value="Save" class="btn2" name="Query" style="height: 60px; width: 90px">
(not yet existing)
here is my exiting code right now:
<SCRIPT LANGUAGE="JavaScript"><!--
function codename() {
if(document.formname.New)
{
document.formname.Add.disabled=false;
document.sapcode.SapCode.disabled=false;
document.lanecode.LaneCode.disabled=false;
document.soldto.SoldTo.disabled=false;
document.soldaddress.SoldAddress.disabled=false;
document.contactperson1.ContactPerson1.disabled=false;
document.deliveredto.DeliveredTo.disabled=false;
document.deliveredaddress.DeliveredAddress.disabled=false;
document.contactperson.ContactPerson.disabled=false;
}
else
{
document.formname.Add.disabled=true;
document.sapcode.SapCode.disabled=true;
document.lanecode.LaneCode.disabled=true;
document.soldto.SoldTo.disabled=true;
document.soldaddress.SoldAddress.disabled=true;
document.contactperson1.ContactPerson1.disabled=true;
document.deliveredto.DeliveredTo.disabled=true;
document.deliveredaddress.DeliveredAddress.disabled=true;
document.contactperson.ContactPerson.disabled=true;
}
}
//-->
</SCRIPT>
<div id="container">
<div id="header">
<div id="img">
<img src="dimensiondata.jpg" alt="dimension data" width="250" height="60">
</div>
<div id="indexno">
<center>Index No.</center> <input type="text" name="indexNo" size="13">
</div>
<form name="formname">
<input type="button" onclick="codename()" id="myButton1" value="New" class="btn" name="New" style="height: 60px; width: 90px">
<input type="submit" disabled value="Add" class="btn1" name="Add" style="height: 60px; width: 90px">
</form>
</div>
Pass this
a reference of event and clicked button to the function like:
<input type="button" onclick="codename(event, this)" id="myButton1" value="New" class="btn" name="New" style="height: 60px; width: 90px">
and try the modifying your function as follows:
function codename(e, elm){
if(elm.type=='button'){
var e = e || window.event;
if(e)
e.preventDefault()
elm.type='submit';
elm.value="Save";
elm.className= 'btn2';
elm.name= "query";
}
//rest of the code
}
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.