JS within PHP.. alert doesn't show up
<p>Edited : I've changed the code as follows and getting an 'NaN' error! Can someone give me a clue as to what that is and a tip to solve? Thanks.</p>

<hr>

<p>Can someone please tell me whats wrong with this code?</p>

<ol>
<li>Firstly, I've called a Javascript within PHP, and is it really possible?</li>
<li>Is there an issue with the way I've called the second alert? (despite whether its possible or not to use js within php) that meant to display the text input and the option selected in a alert message.</li>
<li>Do I need to put 'end of the line' (;) after the last curly bracket of the loop?</li>
</ol>

<p>Here is the code:</p>

<pre><code>&lt;?php
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database");
$SQL="SELECT sbstart, sbend FROM newchk";
$run=mysql_query($SQL,$con) or die ("SQL Error");
$nor=mysql_num_rows($run);
?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;&lt;title&gt;&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function ValidateData() {
var TextIn = document.getElementById('txtN');
    if(TextIn.value == ""){
        alert ("Text field is empty"); 
        return false;
    }else{
        var TextIn = document.getElementById('options');
        alert (&lt;?php $i ?&gt; + TextIn.value);
    }
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form onsubmit="return ValidateData()" method="POST"&gt;
&lt;select STYLE='width:90px'&gt;&lt;?php
while ($rec = mysql_fetch_array($run))
{
    for($i=$rec['sbstart']; $i&lt;=$rec['sbend']; $i++)
    {
        echo "&lt;option id='options' value=''.$i.''&gt;$i&lt;br&gt;&lt;/option&gt;";
    }
}
?&gt;
&lt;/select&gt;
&lt;input type="text" name="txtN"&gt;
&lt;input type="submit" name="subN" value="Save"&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt; 
</code></pre>
