Example:
if the main input value like this "1+23+ " then I need to replace the last special character with a new one suppose I click new special characters like minus, multiplication, and divide symbol, etc.
my expected output:
- when I click the minus symbol > "1+23- "
- when I click the multiplication symbol > "1+23* "
<body>
<input type="text" id="Main">
<input class="ip" type="button" value="1" onclick="Cal(this)">
<input class="ip" type="button" value="2" onclick="Cal(this)">
<input class="ip" type="button" value="3" onclick="Cal(this)">
<input class="ip" type="button" value="+" onclick="Cal(this)">
<input class="ip" type="button" value="-" onclick="Cal(this)">
<input class="ip" type="button" value="*" onclick="Cal(this)">
</body>
<script>
function Cal(btn)
{
document.getElementById("Main").value+=btn.value;
}
</script>