I know they say innerHTML is not safe and can be slow, even though it is now part of HTML5. On the other hand using DOM can be verbose.
What about using a value of e.g. value of a button?
function changeit (valueff, idP){
var change_item = prompt("Change this item",valueff);
if (change_item)
{
document.getElementById(idP).value = change_item;
}
...
It's a restaurant menu made with Codeigniter. So function receives value of a button, and its id and then the value is changed according to admin's input. Then it makes an ajax call to a database and changes the relevant entry. Im planning to sanitize the input of course.
So is the above better than using a textarea and innerHTML?:
document.getElementById(idP).innerHTML = change_item;
The value to be changed could be a line in the menu e.g. Espresso $2.50, it doesnt matter if I use a button as long as the admin can click on it and change the value in the actual menu.
<input id="list_5" type="button" value="Espresso $2.50" onclick="changeit(this.value,this.id);">
EDIT:
If you google why is innerHTML bad - you will get a lot of results, for (example this answer on SO)[Why is "element.innerHTML+=" bad code?