Click to See Complete Forum and Search --> : Javascript Event Problem


Termite
08-12-2003, 05:35 AM
I am experienceing difficulties with certain javascript events.

The javascript function simply submits a form using the code below.

function submitform(form)
{
document.forms[form].submit()
}

When using onclick it doesn't work at all.

Using onmousedown it works for all but one of my links.

Using onmouseover works but takes a while to fire.

The calling script looks like this:

<tr>
<td width=20><img src="Images/Folder_Icon.gif"></td>
<td class=FolderHeading>Six Weekly Local Add Plans</td>
<td></td>
</tr>
<tr>
<td></td>
<td class=FolderDesc>These plans should include all local marketing requests for teletext advertising and direct mail</td>
<td align=right>
<form id="Form2" name="Form2" action="ShowFolder.asp" Method=post>
<input type=hidden name=Folder value="c:\inetpub\wwwroot\mitsu-w\marketingtoolkit\mkt\Six Weekly Local Add Plans\">
</form>
<a href="javascript:"><img src="Images/Arrow.gif" border=0 onclick="submitform('Form2')"></a>
</td>
</tr>

I have attached the full code.

Thanks.

Charles
08-12-2003, 05:43 AM
You've several other problems there as well and the solution to all of them is to stop using JavaScript for this and use a proper submit button, which can be an image.

<form id="Form2" name="Form2" action="ShowFolder.asp" Method=post>
<input type=hidden name=Folder value="c:\inetpub\wwwroot\mitsu-w\marketingtoolkit\mkt\Six Weekly Local Add Plans\">
<input type="image" src="Images/Arrow.gif" alt="Six Weekly Local Add Plans">
</form>

And you're not supposed to use TABLEs for layout.

Termite
08-15-2003, 05:53 AM
I need the javascript code to run as I aim to latter add some form validation. But there is no point writing validation script if the code won't fire.

PS, whats wrong with using tables for layout?

Charles
08-15-2003, 06:10 AM
Originally posted by Termite
I need the javascript code to run as I aim to latter add some form validation.Run the validation from the "onsubmit" handler of the FORM element. and you will not need to use JavaScript to submit the form.
From the HTML 4.01 Specification:
Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.
http://www.w3.org/TR/html4/struct/tables.html#h-11.1Which is to say that it can make the page inaccessible to users using Braille and audio browsers.

Termite
08-19-2003, 06:53 AM
OK so I seem to be approaching the problem in the wrong way.

Thanks for pointing me in the right direction.

However, despite this I have noticed problems with certain javascript events namely the onclick.

Do you know what might be causing this, is there a known bug/issue with certain javascript functions?

Is there a file on my machine that needs udating?