StefanRSA Posted September 24, 2009 Share Posted September 24, 2009 I wrote a js function and am trying to $_Post the value of a hidden field to a form. The function do fire of the php in the background but my hidden field value does not go thru... Can anybody help? (I know this is partly JS and PHP but I get no help in the JS forums) function deleteFileUpload(upload_field){ // Checking file type var filename = document.pictureForm.delimage1.value; document.getElementById('picture_preview').innerHTML = '<div><img src="../images/loader_light_blue.gif" border="0" /></div>'; upload_field.form.action = 'imagedelete.php'; upload_field.form.target = 'upload_iframe'; upload_field.form.submit(); upload_field.form.action = ''; upload_field.form.target = ''; return true; } My hidden field with submit button is: <input type=\"hidden\" id=\"delimage1\" value=\"$dbimgname\" name=\"delimage1\"/><input type=\"submit\" value=\"Delete Image\" onClick=\"return deleteFileUpload(this);\"> The "imagedelete.php" form looks as follow: <?PHP $deleteimage = $_POST['filename']; $filename = "../ad_images/$deleteimage"; $filename1 = "../ad_images/130/$deleteimage"; $filename2 = "../ad_images/65/$deleteimage"; unlink($filename); unlink($filename1); unlink($filename2); // This is a PHP code outputing Javascript code. echo '<script language="JavaScript" type="text/javascript">'."\n"; echo 'var parDoc = window.parent.document;'; $deletebutton = ''; echo "parDoc.getElementById('picture_error').innerHTML = '<input type=\"file\" name=\"img1\" id=\"picture\" onchange=\"return ajaxFileUpload(this);\" />';"; if($dbimgname = '') { echo "parDoc.getElementById('picture_preview').innerHTML = '';"; } echo "\n".'</script>'; exit(); // do not go futher ?> Link to comment https://forums.phpfreaks.com/topic/175324-solved-hidden-field-dont-get-posted-with-function/ Share on other sites More sharing options...
Bricktop Posted September 24, 2009 Share Posted September 24, 2009 Hi StefanRSA, You PHP code has: $deleteimage = $_POST['filename']; But from the name you've given your hidden input field it shoul dbe: $deleteimage = $_POST['delimage1']; Hope this helps. Link to comment https://forums.phpfreaks.com/topic/175324-solved-hidden-field-dont-get-posted-with-function/#findComment-923972 Share on other sites More sharing options...
StefanRSA Posted September 24, 2009 Author Share Posted September 24, 2009 Thanks Bricktop.... Now it works but for some reason its running the function correctly only once.... Link to comment https://forums.phpfreaks.com/topic/175324-solved-hidden-field-dont-get-posted-with-function/#findComment-923980 Share on other sites More sharing options...
StefanRSA Posted September 24, 2009 Author Share Posted September 24, 2009 Got it al working now!!!! THANKS!!! Link to comment https://forums.phpfreaks.com/topic/175324-solved-hidden-field-dont-get-posted-with-function/#findComment-923982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.