提交按钮影响多个文件 [英] Submit button to affect multiple files
问题描述
当前情况:
因此,对于文章页面(article.php
),我有2个不同的部分(标题,内容),它们是从各自的php文件中钩接到文章页面的(标题是从title.php
提取的,而内容是被提取的)来自content.php
).
So, for an article page (article.php
), I have 2 different sections (title, content), which are hooked to the article page from their own php files (Title is pulled from title.php
while content is pulled from content.php
).
现在,我为作者增加了编辑文章标题和内容的功能,他们需要按submit
按钮才能保存更改.
Now, I added an ability for the author to edit the title and content on the article which they need to press submit
button in order save the change.
问题
编辑后,作者需要按提交"按钮以更新数据.
但是,当我在"title.php
"或"content.php
"中放置提交"按钮时,只有相应的节被更新而另一个未更改(例如,如果我在title.php
中具有此submit
按钮,则仅title
已被编辑).
After editing, the author needs to press "Submit" button in order to update the data.
However, when I put the "submit" button in either title.php
or content.php
, only the corresponding section is updated while the other is unchanged (for example, if I have this submit
button in the title.php
then only title
is edited).
如果我将按钮放在article.php
中,则标题和内容当然都不会更新.
If I put the button in the article.php
then of course neither the title nor content gets updated.
以下是标记:
Article.php:
Article.php:
<div class="article">
<?php do_action ('article_summary'); ?>
</div>
Title.php(带有submit
按钮,仅更新标题)
Title.php (with the submit
button, which only updates the title)
<form role="form" method="post">
<div class="edit_title">
<input type="hidden" value="<?php echo $post_id; ?>">
<?php post_input_box( $post_id, 'post_title', array( 'placeholder' => 'Article title..', 'value' => $post->post_title ) ); ?>
<div class="update-button-wrap">
<input type="submit" name="update_product" value="<?php esc_attr_e( 'Update', 'site' ); ?>"/>
</div>
</div>
</form>
Content.php
Content.php
<form role="form" method="post">
<div class="edit_content">
<?php post_input_box( $post_id, 'post_content', array( 'placeholder' => 'Short description..', 'value' => $post->post_content ), 'textarea' ); ?>
</div>
</form>
有人知道提交按钮如何将标题和内容保存在两个不同的文件中吗?
Does anyone know how the submit button can save both title and content that are in two different files?
感谢一群人!
推荐答案
尝试使用超级按钮(正在申请专利),将所有其他按钮都按入...
Try using a super-button (pattent pending) that presses all them other buttons for ye...
<button type='button' onclick="$('[type="submit"]').click()">Submit</button>
由于使用了类型"按钮,因此它不会提交自己.以此替换每个提交按钮.我的意思是,将原始按钮留在那里,但是用
Since its type button, it won't submit itself. Replace each submit button with this. I mean, leave the original buttons there, but style them with
button[type="submit"] { display:none }
这篇关于提交按钮影响多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!