Forum Moderators: open
echo "<form name=\"char\" action=\"clients.php\" method=\"post\">";
echo "<input name=\"val\" type=\"hidden\" value=\"\">";
$c = "a";
for ($i=0;$i<26;$i++) {
echo "<a href=\"javascript:submitform();\" onMouseOver=\"change('".$c."')\">".strtoupper($c)."</a>\n\t";
$c++;
}
echo "</form>";
I have this JavaScript for the links
<script language="JavaScript" type="text/javascript">
function submitform() {document.char.submit() }
function change($ch) {document.char.val.value=$ch;}
</script>
The change function changes the value in the hidden field to the link selected. This all works fine in IE but for some reason it wont submit in FireFox
Any ideas on what I'm doing wrong?
Thanks
Since this is the javascript forum, when posting code snippets, it would be more helpful if you posted html source code rather than php.
In general, when trying to figure out why javascript code won't work, it is always helpful to open a javascript console (to display error messages). I reckon Opera is best for this, closely followed by Firefox.
Kaled.
<form name="char" action="clients.php" method="post">
<input name="val" type="hidden" value="">
<a href="javascript:submitform();" onMouseOver="change('a')" class="links">A</a>
<a href="javascript:submitform();" onMouseOver="change('b')" class="links">B</a>
<a href="javascript:submitform();" onMouseOver="change('c')" class="links">C</a>
<a href="javascript:submitform();" onMouseOver="change('d')" class="links">D</a>
(ALL THE WAY TO Z)
</form>
Then the same JavaScript above is used for the functions:
I have this JavaScript for the links
<script language="JavaScript" type="text/javascript">
function submitform() {document.char.submit() }
function change($ch) {document.char.val.value=$ch;}
</script>
Cant for some reason get it to work in Firefox
Thanks
Error: missing name after . operator
Source File: [***********...]
Line: 8, Column: 32
Source Code:
function submitform() {document.char.submit() }
Plus this:
Error: submitform is not defined
Source File: javascript:submitform();
Line: 1
And this:
Error: change is not defined
I'm confused?!?!?!?
The following code worked for me:
function submitform()
{
document.forms["char"].submit();
}
function change(ch)
{
document.forms["char"].val.value = ch;
}