javascript php从动态添加的文本框中获取值 [英] javascript php get value from a dynamically added textbox

查看:111
本文介绍了javascript php从动态添加的文本框中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用它来动态生成文本框:`

i'm using this to generate a textbox dynamically:`

<html>
<head>
<title>Dynamic Form</title>
<script type="text/javascript" >
function CreateTextbox()
{
var i = 6;
createTextbox.innerHTML = createTextbox.innerHTML +"<input type=text name='flow'+ i/>"
i++;
}
</script>
</head>
<body>

<form name="form" action="post" method="">
<input type="button" value="clickHere" onClick="CreateTextbox()">
<div id="createTextbox"></div>
</form>
</body>

如何从添加的文本框中获取值?

how can i get the value from the added textbox?

我正在使用javascript和php。

i'm using javascript and php.

推荐答案

将生成的ID添加到文本框并使用此ID检索输入

Add a generated ID to the textbox and use this ID to retrieve the input

function CreateTextbox()
{
  var i = 6;
  createTextbox.innerHTML = createTextbox.innerHTML +"<input type=text name='flow'+ i id='box'+i/>"
  i++;
}

function getBox(var id){
  return document.getElementById("box"+i);
}

这篇关于javascript php从动态添加的文本框中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆