I am trying to check user input before displaying the correct HTML element.
Here is my code:
<script>
var additem = '<div><div class="itesm">' +
'<h1>'+itemname+'</h1>';
if(itype == 'edit'){
additem .= '<div><input id="itemdis" value="'+itemdis+'"></div>';
}else{
additem .= 'Good item';
}
additem .= '</div>';
$('showitem').html(additem);
</script>
I always do something like this in PHP, but I can't figure out how to do it in javaScript.
Can anyone tell me how to concatenate the strings together so that my example works?