多个文本框有帮助 [英] Multiple Text Boxes help

查看:70
本文介绍了多个文本框有帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个表单,要求用户定义问题的数量(这只是从下拉菜单中),根据他们选择的数字,他们将被要求在单独的文本框中定义每个问题(每个问题的一个文本框)。因此,如果他们选择2作为问题的数量,他们将被给予两个文本框,5个框用于从下拉列表中选择5。

我想我需要一些javascript(用于表单验证),一些用于表单邮件的PHP,但它是动态文本框我完全失去了。

有人能指出我正确的方向吗?

解决方案


但它是动态文本框我完全失去了。



i为此目的推荐javascript和DHTML

你应该在你的HTML中有类似的东西 - < div id =''textboxes' '>< / div>


带有数字的下拉列表可以调用我在下面为你写的函数

展开 | 选择 | Wrap | 行号


我试过这个;


< html>

< head>



< / head>


< body>


< select名称= QUOT;盒" onChange =" boxes()">

< option value ="">选择< / option>

< option value =" 1"> 1< / option>

< option value =" 2"> 2< / option>

< / select>

< script type =" text / javascript">

功能框(NumberOfBoxes){

for(i = 0; i< NumberOfBoxes; i ++ ){

box + ="< textarea name =''textbox [NumberOfBoxes]''>< / textarea>" ;;

}

document.getElementById(''textboxes'')。innerHTML = boxes;

}

< / script>

< div id =''textboxes''>

盒子应该到这里

< / div>

< / body>


< / html>

它只提供一个带有大量脚本的文本框:-(


想想我明天再去上班。


< selec t name =" boxes" onChange =" boxes()">


//盒子需要一个参数number文本框

//你需要将选项值传递给它,例如盒子(2);

//你可以试试这个盒子(this.value); - 我不确定这是否有效

//但你需要以某种方式传递一个值


问候

JX2

I need to write a form that asks the usser to define the number of problems (this is simply from a dropdown menu), depending on the number they select they will be asked for a definition of each problem in a seperate text box (one text box for each problem). So if they pick 2 as the number of problem they will be given two text boxes, 5 boxes for selecting 5 from the drop down list.
I think I need some javascript (for form validation), some php for the form-mailer, but it''s the dynamic text boxes I''m at a total loss at.
Can anyone point me in anything like the right direction?

解决方案

but it''s the dynamic text boxes I''m at a total loss at.

i recomend javascript and DHTML for that purpose
you should have something like that in your HTML - <div id=''textboxes''></div>

drop down list with a numbers can call a function i wrote for you below

Expand|Select|Wrap|Line Numbers


I tried this;

<html>
<head>


</head>


<body>

<select name="boxes" onChange="boxes()">
<option value="">choose</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<script type="text/javascript">
function boxes(NumberOfBoxes){
for(i=0;i<NumberOfBoxes;i++){
boxes += "<textarea name=''textbox[NumberOfBoxes]''></textarea>";
}
document.getElementById(''textboxes'').innerHTML = boxes;
}
</script>
<div id=''textboxes''>
boxes should go here
</div>
</body>

</html>
and it give only one text box with loads of script showing :-(

Think I''ll have another go at work tomorrow.


<select name="boxes" onChange="boxes()">

// boxes need one parameter "number" of textboxes
// u need to pass option value to it, e.g. boxes(2);
// u might try this boxes(this.value); - i''m not sure if that will work
// but u need to pass a value somehow

regards
jx2


这篇关于多个文本框有帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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