0

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.

3 Answers 3

1

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/

Sign up to request clarification or add additional context in comments.

2 Comments

can I have a dynamic article id with this?
do you mean something like: data: { article_id: article_var, images: { i1: "img1", i2: "img2" } }
0

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.

2 Comments

This opens new tab instead of a popup window and if I create a popup window, most users have popups blocked. any way around it? I really like the ajax modal popup, but don't know enough about it to implement it whilst passing php variables to it. Any ideas or or a nudge in the right direction will be very helpful. Thanks
the browser takes control of popups. he decides whether it is a new tab or a popup window
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.