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,

PHP Code:
<script type="text/javascript" language="JavaScript">
dimValidator() {
numericExpression = /^[0-9]+$/;
m.match(numericExpression) && n.match(numericExpression) && m!="0" && n!="0"){ //Check both conditions
var newHTML "<table class=\"matrix_index\" border=\"0\">";
for (i=1i<=mi++){
newHTML newHTML "<tr>";
            for (
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
document.getElementById('dimension').innerHTML "Insert table dimension";
HTML Code:
<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>