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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.