Multiple posting using JavaScript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Multiple posting using JavaScript

Post by mjseaden »

Dear All

Code: Select all

<TD HEIGHT="30" WIDTH="80" BGCOLOR="#000066" STYLE="padding-left:15px" ALIGN="CENTER"><INPUT TYPE="hidden" NAME="input2" VALUE=""/><A HREF="javascript:document.datapost.input2.value='preview';document.datapost.action="run2.php?p=24";document.datapost.submit()"><IMG SRC="preview.jpg" STYLE="border:none"></A></TD>
            <TD HEIGHT="30" WIDTH="515" BGCOLOR="#000066" STYLE="padding-left:15px"><INPUT TYPE="hidden" NAME="input3" VALUE=""/><A HREF="javascript:document.datapost.input3.value='clear';document.datapost.action="run2.php?p=26";document.datapost.submit()"><FONT COLOR="#FFFFFF"><IMG SRC="clear.jpg" STYLE="border:none"></A></TD>
            <TD HEIGHT="30" WIDTH="85" BGCOLOR="#000066" STYLE="padding-right:10px" ALIGN="CENTER"><A HREF="javascript:document.datapost.input4.value='submit';document.datapost.action="run2.php?p=25";document.datapost.submit()"><IMG SRC="submit.jpg" STYLE="border:none"></A></TD>
This code, amongst other code, is enclosed by a FORM with the name 'datapost'. The idea of this is to enable me to use image-based buttons to submit the values in various INPUT objects on the page to different URLs.

However, IE is telling me that this script is causing errors. Can anyone tell me what's wrong?

If this is not the way to do it, can anyone tell me another way to do it?

Many thanks

Mark
Farrier
Forum Newbie
Posts: 12
Joined: Thu Mar 25, 2004 10:39 am

Post by Farrier »

This gave me some fairly endless grief.

The following SEEMS TO WORK for most browsers that I've tried it on.

I do not claim that it is canonical, though.

Code: Select all

<FORM NAME="form1" TARGET="myotherscript.php">
<INPUT TYPE="submit" VALUE="Refresh dropdown lists" ONCLICK="javascript:document.form1.action=myscript.php'">
...
Simple, hmn? Just change the URL you want it to submit to, from 'myscript.php' to something else, and "form1" to whatever your form is called.

That means your form MUST have a NAME= tag, as shown above.
Post Reply