HollyVally
Programmer
Hi all,
Here is how I have organised the structure:
a) all the js scripts are in file -- 'scriptfile.js'
b) all the HTMLs are created on the fly from a PHP script.
However, I haven't given the PHP - rather the output as I have got fron view source file!
HTML generation are done in 3 steps: Pick-a-choice, buffer-zone, Put-the-choice(see the code pls.)
which are individually created for the user-end.
[bold]Problems facing[/bold]: 1) none of the inline function-calls from the HTML section reaches the scripts
2) but if 'alert()' is used instead of calling the local function the alert comes up when clicked!
Can any one pls spot the problem and explain me where did I do wrong?
In my file scriptfile.js I have the following:
<SCRIPT language = "javascript">
<!--
function shouldset(passon){
chosenNumber(passon)
}
function chosenNumber(elem){
document.form.chosenNumber.value=elem
document.form.YouHaveChosen.value='You have chosen'+elem
}
function setChosenNumber(cell){
crossNumber."cell"+cell.value=crossNumber.chosenNumber.value
crossNumber.YouHaveChosen.value="Click now!"
crossNumber.chosenNumber.value=""
}
//-->
</script>
... and in my scriptfile.html I have the following form created through PHP:
<FORM action="CN.php" method="post" enctype="multipart/form-data" name="formCN">
<table cellspacing="0" cellpadding="0"><!-- table 1 -->
<TR>
<TD colspan="10" class="number">To choose a number<BR>Click on it</td>
</tr>
<TR><!-- Pick Choice -->
<td class="number"><A href="javascript:chosenNumber('1');>1</A></TD>
<td class="number"><A href="javascript:chosenNumber('2');>2</A></TD>
...
<td class="number"><A href="javascript:chosenNumber('9');>9</A></TD>
<td class="number"><A href="javascript:chosenNumber('0');>0</A></TD>
</TR>
<TR><!-- buffer zone -->
<TD colspan="10" class="number">
<INPUT type="text" name="chosenNumber" value="" onChange="shouldset(this.value)">
<INPUT type="text" name="YouHaveChosen" class="gamecell" value="Click Now!" onChange="shouldset(this.value)" size="30" readonly>
</td>
</tr>
</table>
<table class="number" cellspacing="0" cellpadding="0"><!-- Table 2 -->
<tr><!-- Put Choice -->
<td><input name="cell1" type="text" class="number" value="1" onClick="setChosenNumber(this.formCN.cell1.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
<td><input name="cell2" type="text" class="number" value="2" onClick="setChosenNumber(this.formCN.cell2.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
...
<td><input name="cell5" type="text" class="number" value="5" onClick="setChosenNumber(this.formCN.cell5.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
</tr>
</form>
Here is how I have organised the structure:
a) all the js scripts are in file -- 'scriptfile.js'
b) all the HTMLs are created on the fly from a PHP script.
However, I haven't given the PHP - rather the output as I have got fron view source file!
HTML generation are done in 3 steps: Pick-a-choice, buffer-zone, Put-the-choice(see the code pls.)
which are individually created for the user-end.
[bold]Problems facing[/bold]: 1) none of the inline function-calls from the HTML section reaches the scripts
2) but if 'alert()' is used instead of calling the local function the alert comes up when clicked!
Can any one pls spot the problem and explain me where did I do wrong?
In my file scriptfile.js I have the following:
<SCRIPT language = "javascript">
<!--
function shouldset(passon){
chosenNumber(passon)
}
function chosenNumber(elem){
document.form.chosenNumber.value=elem
document.form.YouHaveChosen.value='You have chosen'+elem
}
function setChosenNumber(cell){
crossNumber."cell"+cell.value=crossNumber.chosenNumber.value
crossNumber.YouHaveChosen.value="Click now!"
crossNumber.chosenNumber.value=""
}
//-->
</script>
... and in my scriptfile.html I have the following form created through PHP:
<FORM action="CN.php" method="post" enctype="multipart/form-data" name="formCN">
<table cellspacing="0" cellpadding="0"><!-- table 1 -->
<TR>
<TD colspan="10" class="number">To choose a number<BR>Click on it</td>
</tr>
<TR><!-- Pick Choice -->
<td class="number"><A href="javascript:chosenNumber('1');>1</A></TD>
<td class="number"><A href="javascript:chosenNumber('2');>2</A></TD>
...
<td class="number"><A href="javascript:chosenNumber('9');>9</A></TD>
<td class="number"><A href="javascript:chosenNumber('0');>0</A></TD>
</TR>
<TR><!-- buffer zone -->
<TD colspan="10" class="number">
<INPUT type="text" name="chosenNumber" value="" onChange="shouldset(this.value)">
<INPUT type="text" name="YouHaveChosen" class="gamecell" value="Click Now!" onChange="shouldset(this.value)" size="30" readonly>
</td>
</tr>
</table>
<table class="number" cellspacing="0" cellpadding="0"><!-- Table 2 -->
<tr><!-- Put Choice -->
<td><input name="cell1" type="text" class="number" value="1" onClick="setChosenNumber(this.formCN.cell1.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
<td><input name="cell2" type="text" class="number" value="2" onClick="setChosenNumber(this.formCN.cell2.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
...
<td><input name="cell5" type="text" class="number" value="5" onClick="setChosenNumber(this.formCN.cell5.name);this.blur()"><img border="0" src="../images/fill.gif" width="10" height="10"></td>
</tr>
</form>