Jump to content

My function is not working, what am I doing wrong?


StefanRSA

Recommended Posts

I have a function:

function deleteimage1(){
var image1Field = document.getElementById('image1');
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;
}

I am trying to get the value of field with ID 'image1' and then post the value to the imagedelete.php file so I can delete an image without refresh.

 

This is not working??? Can anybody please help me?

Link to comment
Share on other sites

  • 3 weeks later...

to be honest I'd recommend using jQuery to achieve this!

 

It would be as simple as:

 

var filename = jQuery('#image1').val();
jQuery.post('imagedelete.php', { filename: filename  });

 

You imagedelete.php file would need to be looking for $_POST['filename'], but this is easily changeable...

Link to comment
Share on other sites

I have a function:

function deleteimage1(){
var image1Field = document.getElementById('image1');
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;
}

I am trying to get the value of field with ID 'image1' and then post the value to the imagedelete.php file so I can delete an image without refresh.

 

This is not working??? Can anybody please help me?

 

I don't see any ajax transport used here... You are actually posting the whole form to imagedelete.php.

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.