Why doesn't this work?

Michael Pyne pynm0001 at comcast.net
Wed Apr 27 06:43:33 BST 2005


I'm trying to submit a form with Javascript.  It doesn't seem to work right in 
Konqueror for some reason (KHTML CVS).

Sample code:
<html>
<head>
<script language="javascript1.1">
<!--
function submitAction(prog)
{
    /* The following HTML has the appropriate form element with
     * name = "reqForm"
     */
    if(!document.reqForm)
    {
	window.alert("reqForm not found");
	return;
    }

    document.reqForm.reset();
    document.reqForm.program_id.setAttribute("value", prog);
    document.reqForm.submit(); /* Nothing doing. :( */
}
-->
</script>

</head>
<body>
<form name="reqForm" method="post" action="$script_name">
<input name="request" type="hidden" value="edit"/>
<input name="program_id" type="hidden" value="-1"/>
</form>

<!-- Listing of various programs follows, example: -->
<a href="#" onClick="submitAction(1)">Program 1</a><br>
<a href="#" onClick="submitAction(2)">Program 2</a><br>
</body>
</html>

Basically what I'm trying to do is write a frontend for my personal use, which 
just displays a list of hyperlinked programs (generated via CGI script), 
which, when clicked, just runs the script again, but with the appropriate 
form variables filled out.

This works in Firefox 1.0.3, as did an alternate technique I tried of creating 
the form and the input elements dynamically.  Neither method seems to work in 
KHTML.  Instead of going to the specific page for the program, KHTML either 
reloads the page it was on (listing of programs), or goes back to the default 
page that is displayed when the user first runs the script. :(

I'd appreciate any advice/pointers.

Regards,
 - Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050427/df3f8176/attachment.sig>


More information about the kfm-devel mailing list