Accipiter Posted January 15, 2007 Share Posted January 15, 2007 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! Quote Link to comment Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 Any hidden variable will be submitted... what's the problem? Quote Link to comment Share on other sites More sharing options...
Accipiter Posted January 15, 2007 Author Share Posted January 15, 2007 Well, I realizes that, what I suggested myself worked pretty well :-[But what problem still remains is that the value of the Submit-button "send" will not be sent through the link.Can I make it somehow? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 Well, I guess you could "click" on that button via JS, which should trigger it. Quote Link to comment Share on other sites More sharing options...
Accipiter Posted January 15, 2007 Author Share Posted January 15, 2007 Taking your suggestion, I tried.Yay! It worked, just like I wanted it to.Thanks alot for the help!It might have sounded trivial, but just JS is completely new to me and I just had no idea what I could and couldn't do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.