简体   繁体   中英

html php javascript form popup

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.

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/

检查一下: http : //www.malsup.com/jquery/form/-jQuery是先决条件,但插件允许您通过ajax发送表单元素,包括使用简单API的文件字段,并且为您完成了所有繁重的工作。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM