Jump to content

Submit form: Need submit link to send additional value


Accipiter

Recommended Posts

Hi all,

I am doing a form for uploading/editing an image in an online gallery.
The form passes data to the PHP script by the Post method, and if the submit button has been clicked, the data is checked, fixed and finally uploaded to the DB.

Now, what I also want is to have a link (for those with js enabled browsers) for editing the thumbnail. If one presses the link a normal submit should be sent, but in addition, another value should be set to [color=green]true[/color] so that after the data has been updated in the DB, the PHP script should redirect to the thumbnail edit page if this value is set.

From what I've read so far on the net, I can't directly use the POST with Javascript, but will have to send the data through the form. Can I have a hidden value that I can change with the script then?

I am completely new to Javascript though.

[code]<script type="text/javascript">
<!--
function thumbsubmit()
{
  var x=document.getElementById("formtable_form");
  x.editthumb.value=1;
  x.submit();
}
//-->
</script>

<form action="upload.php" enctype="multipart/form-data" method="post" name="formtable_form">
<input type="hidden" name="editthumb" value="0" />
..

<script type="text/javascript">
<!--
document.write('<br /><a href="javascript:thumbsubmit();">Edit thumbnail<\/a>');
//-->
</script>

...

<input type="submit" name="send" value="Submit" />
</form>[/code]

Okay.. I don't even know if it this code works. Will that Hidden field be changed before submitted? And if I write like this, the "send" will not be submitted, but I would need it to be sent too.

Any help and/or suggestions is welcome!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.