×

php输出文本框值

php输出文本框值(php给文本框赋值)

admin admin 发表于2023-02-23 21:38:07 浏览119 评论0

抢沙发发表评论

本文目录一览:

用PHP在数据后循环输出文本框

思路:

1、构建form表单,输出文本框,用textarea/textarea吧,input/内不能换行,页面效果也不好(php、html代码嵌套写的话,直接写就行,建议用smarty,php与模板分离,比较清晰)-php输出文本框值

2、提交内容,确定用什么method(post、get)

3、获取内容,$str=$_POST['name'](name为textarea的name值)

4、$arr=split ('\r\n', $str);按换行符分割字符串为数组

5、循环执行插入语句,$arr每一层都是一条数据

PHP中 怎么样实现从一个文本框中读取数值然后在另一个文本框中输出呢

可以使用POST也可以使用GET方式进行传递,比如

form action="" method="post"

input type='text' name="username"

input type="submit"

/form

?php

if(isset($_POST['username']))

{

$username = $_POST['username'];

}

echo 'input type="text" value="$username"';

?

大体是这样,但是这只是个样板~~~

PHP 怎么把字符串输出到文本框

也可以这样

if($x==100)

{

input type="text" name="nox"  value=“满足时候的值” /

}else{

input type="text" name="nox" value="不满足时候的值" /

}

PHP 输出文本框内容到变量 然后抓取内容

?php

header("Content-type: text/html; charset=utf-8");

if(!empty($_POST['input_text'])) {

$data = file_get_contents( $_POST['input_text'] );

$charset_pos = stripos($data,'charset');

if($charset_pos) {

if(stripos($data,'utf-8',$charset_pos)) {

echo iconv('utf-8','utf-8',$data);

}else if(stripos($data,'gb2312',$charset_pos)) {

echo iconv('gb2312','utf-8',$data);

}else if(stripos($data,'gbk',$charset_pos)) {

echo iconv('gbk','utf-8',$data);

}

return;

}

echo $data;

}else {

?

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""

head

titleGet Web Page/title

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

meta http-equiv="Content-Language" content="zh-CN" /

script type="text/javascript"

function createXMLHTTP()

{

try

{

var request = new XMLHttpRequest();

}

catch(e1)

{

var arrVersions = ["Microsoft.XMLHTTP","MSXML2.XMLHttp.4.0",

"MSXML2.XMLHttp.3.0","MSXML2.XMLHttp.5.0"];

for(var i=0;i  arrVersions.length;i++){

try{

request = new ActiveXObject(arrVersions[i]);

}catch(e2){

request = false;

}

}

}

return request;

}

function ajax_post(url, params, target_id)

{

request = new createXMLHTTP();

request.onreadystatechange = function() {

if (this.readyState == 4)

if (this.status == 200)

if (this.responseText != null)

document.getElementById(target_id).innerHTML = this.responseText;

}

request.open("POST", url, true);

request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");-php输出文本框值

request.setRequestHeader("Content-length", params.length);

request.setRequestHeader("Connection", "close");

request.send(params);

}

var checked = false;

function check_(value) {

checked = value;

}

function get_key(event) {

event = event || window.event;

if(event.keyCode==13  checked != false)

{

var url = document.getElementById('input_text').value;

if(url != '') {

get_page();

}else {

document.getElementById('input_text').onfocus();

return false;

}

}

}

function get_page() {

var url = document.getElementById('input_text').value;

if(!url) {

return false;

}else {

if(document.getElementById('output_page').innerHTML != '') {

document.getElementById('output_page').innerHTML = '';

}

}

if(url.indexOf('http://') == -1) {

url = 'http://'+url;

}

ajax_post(

'get_web.php',

'input_text='+url,

'output_page'

);

document.getElementById('click_show').style.display = 'block';

document.getElementById('back_a').href = document.location.href;

document.getElementById('origin_website').href = url;

}

/script

style

.div_box{

margin-top:10px;

}

.input_box{

border:1px solid;

margin-left:10px;

margin-top:2px;

height:15px;

float:left;

size:32

font-size: 14px;

}

.button_box{

float:left;

height:23px;

padding-bottom:3px;

}

.hide_box{

display:none;

}

.a_box{

margin-left:10px;

margin-top:3px;

height:15px;

float:left;

font-size: 14px;

}

.clear_box{

height:50px;

}

/style

/head

body onkeydown="get_key(event)"

div class="div_box"

input id="input_text" class="input_box" type="text" value="" onclick="check_(true)" onblur="check_(false)"/input-php输出文本框值

input type="button" class="button_box" onclick="get_page()" value="Get it!" /input-php输出文本框值

div id="click_show" class="hide_box"

a id="origin_website" class="a_box" href="#" target="_black"访问原站/a-php输出文本框值

a id="back_a" class="a_box" href="#"后退/a

/div

/div

div class="clear_box"/div

div id="output_page"/div

/body

/html

?php

}

//End_php