Hello all!

So, I'm creating an interactive website and one of the functions requires the user to insert the table values (lines and columns) and the JavaScript script immediately generates the code for it.

The problem is that the innerHTML is creating a unexplained line break immediately after the table dimensions.

Once you run the code, the phrase "Insert table dimension" appears where it is supposed to be, next to the table dimensions, with no line break. Once you input some table dimensions (1,1) and you then insert unvalidated characters in the input field (a,a) the phrase "Insert table dimension" appear with a line break.

Anyone have a solution for this problem?

Kind regards,
Amoguai

PHP Code:
<script type="text/javascript" language="JavaScript">
<!--
function 
dimValidator() {
    var 
document.getElementById('A_m').value;
    var 
document.getElementById('A_n').value;
    var 
numericExpression = /^[0-9]+$/;
    if(
m.match(numericExpression) && n.match(numericExpression) && m!="0" && n!="0"){ //Check both conditions
        
var newHTML "<table class=\"matrix_index\" border=\"0\">";
        
alert
        
for (i=1i<=mi++){
            
newHTML newHTML "<tr>";
            for (
j=1j<=nj++){
                
newHTML newHTML "<td>" ",""<input size=\"3\" type=\"text\" name=\"" "x" "\" /></td>";
            }
            
newHTML newHTML "</tr>";
        }
        
document.getElementById('dimension').innerHTML newHTML//Injects the new HTML code into the page
    
}else{
        
document.getElementById('dimension').innerHTML "Insert table dimension";
    }
}
//-->
</script> 
HTML Code:
<html>
<body>
<form>
Table
<p><input type="text" name="A_m" id="A_m" size="4" onKeyUp="dimValidator()" /> x <input type="text" name="A_n" id="A_n" size="4" onKeyUp="dimValidator()" /><span id="dimension">Insert table dimension</span></p>
</form>
</body>
</html>