Reputation: 565
Apologies for the ambiguous title, it just goes to show how confused I am with this one.
<a href"page.php?article_id=123&&img_id=img1">change image</a>
The link above is inside a form and is supposed to allow a user to change the image on an article. The functional php side of things is sorted - uploading the image, changing the image etc, but this will require the main form being submitted which is fine for the initial upload - not so much for the edit.
When the user clicks the "change image" link, I would ideally like to process that particular request alone in a different form, then update the parent page. I thought of doing it with a javascript new window popup which would have been ideal, except that I can't figure out how to pass the article_id
as well as the img_id
to the new popup page but above all... is this the most efficient way of doing this nowadays?
If not, How do I carry out this task? I have thought of ajax, jquery... but the same issue of passing the article_id
and img_id
still limits me.
I hope all of this makes sense and thanks in advance
ps: An article can have multiple images and article id is dynamic.
Upvotes: 0
Views: 1413
Reputation:
why cant u receive article_id and img_id?
if you use:
<a href"#" onclick="window.open('page.php?article_id=123&&img_id=img1', 'window1');">edit</a>
u can get article_id and img_id in $_GET
however, this is a oldfashioned way getting this done.
Upvotes: 0
Reputation: 1024
Check this up: http://www.malsup.com/jquery/form/ - jQuery is a prerequisite but plugin allows you to send form elements via ajax, including file fields using simple API and does all heavy lifting for you.
Upvotes: 0
Reputation: 324
ajax sounds good to me. may be you try something like this (jquery)?!
$.ajax({
type: "POST",
url: "page.php",
data: { article_id: 123, images: { i1: "img1", i2: "img2" } }
}).done(function( msg ) {
alert( "done: " + msg );
});
for further information and examples: http://api.jquery.com/jQuery.ajax/
Upvotes: 1