I have 2 fields prefix and value. Suppose when I put prefix as A and value as 10, it should give me result A1 to A10. In my code it gives me result A1 to A10 but at start it appends value too. That means it gives 10A1 instead of only A1. Thank you. Sorry for grammar.
function saveForm(){
var val = document.getElementById("val").value;
var prefix = document.getElementById("prefix").value;
for(i=1; i<=parseInt(val); i++){
val += prefix + i + "<br>";
}
document.getElementById("demo").innerHTML = val;
}
<label>Prefix</label>
<input id="prefix" name="prefix" type="text" /><label>Value</label><input id="val" type="text" />
<button type="button" onClick="saveForm()" />Save</button>
<p id="demo"></p>