简体   繁体   English

如何打印 <form action> ?

[英]How to print from <form action>?

I have the following code in post.php: 我在post.php中有以下代码:

    <?php
set_magic_quotes_runtime(0);

if (isset($_GET['debug'])) {
    echo '<pre>';
    print_r($_POST);
} else {
    echo stripslashes($_POST['editor']) ;
} 

And at the main page there is a form button that calls post.php with a post action and export everything within a div. 并且在主页上有一个表单按钮,该表单按钮使用后期操作调用post.php并导出div中的所有内容。 How can configure it to print the exported page when I click that form button? 当我单击该表单按钮时,如何配置它以打印导出的页面?

AJAX, PHP, JQUERY, JAVASCRIPT ??? AJAX,PHP,JQUERY,JAVASCRIPT ???

In order to obtain anything from a submitted form (method=post) in PHP, there is the global $_POST as you have discovered. 为了从PHP的提交表单(方法=帖子)中获取任何内容,您已经发现了全局的$_POST The keys (debug, editor) in that array correspond to the name attributes of select, textarea and input fields from the submitted form. 该数组中的键(调试,编辑器)对应于提交表单中的select,textarea和input字段的名称属性。 They are not the same as jQuery selectors, meaning you can not export everything from a div unless you use JavaScript to set the value attribute of an input to the content of that div. 它们与jQuery选择器不同,这意味着您无法从div导出所有内容,除非您使用JavaScript将输入的value属性设置为该div的内容。

crude example: 粗略的例子:

<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>

<script>
$(document).ready(function(){

    $('input[name="post"]').click(function(ev){
        ev.preventDefault();

        console.log('click');
        $('form').append(
            $('<input name=div type=hidden>').val($('div').html())
        );

        setTimeout(function(){
            $('body').prepend('SENDING<br>');
            $('form').submit();
        }, 333);
    });
}
);
</script>

</head>
<body>
<form method="POST" action="moo.php">
<textarea name="summary" cols=80 rows=3>
Zuma is a big man
</textarea>
<br>

<input type="text" name="what" value="zuma?">
<br>

<select id="" name="">
<option value="55">schfifty five</option>
<option value="2">doo</option>

</select>
<br>

<input type="submit" name="post" value="send">
</form>
<pre>
<?php print_r($_POST); ?>
</pre>

<div> random stuff <span> foobar </span>
</div>

<body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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