在每个按钮单击上添加具有多个控件的行 [英] Add rows with mutiple controls on each button click

查看:60
本文介绍了在每个按钮单击上添加具有多个控件的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[HTML]< form name = frm action ="" method =" post">

< table>

< tr>< td>< select name = combo>

<选项> 1< /选项>

<选项> 2< /选项>

<选项> 3< /选项>

< option> 4< / option>

< / select>

< td>< input type =" text" name = tb1 value ="">< / td>

< td>< input type =" text" name = tb2 value ="">< / td>

< td>< input type =" text" name = tb3 value ="">< / td>

< / tr>

< input type =" submit" name = submit value = AddRow>

< / table>

< / form> [/ HTML]

大家好。这是一个简单的html设计的代码。这里的所有控件都在一行。

除此之外,还有一个提交按钮

我的真正问题现在开始。

我应该做的是编写一些代码,使得每次单击AddRow按钮时都会产生
,生成所有这些控件的新行。

例如,在第一次单击按钮时,会生成一个这样的行,其中包含一个列表/菜单框和三个文本框。

在下一次单击时,我有另一个这样的行,并且在所有两行。

第三次点击我有三行等等。

这一切都是在php中完成的。我有一些想法,但这不值得实现。

我在javascript中制作一些增量函数,可以在addrow按钮的onclick事件中调用。

虽然它没有太多的帮助,所以如果有人可以帮助我,欢迎你。请继续。


谢谢和rergards

TechnoAtif

解决方案

用PHP完成它是否至关重要?


我的意思是,只使用javascript就意味着没有新的页面请求,因此消耗的资源更少。


问候。


您好Markusn,

感谢您的快速回复如果它可能是整个和唯一的JavaScript,那么它也有很大帮助,至少我能够得到它背后的概念。但是如果它可以使用PHP完成,它可能对我更好。但没问题如果它在javascript中。


谢谢和问候

TechnoAtif


是的,我在想你需要javascript。或者AJAX会更好。但是为了扩展markus的帖子,我很抱歉,如果你已经知道这一点,只值得确保我们在同一页面上!


php是服务器端,所以要使用php重新生成代码,你需要再次请求页面,这通常意味着刷新页面。 Javascript是客户端,这意味着它可以在不刷新(简化)的情况下更改代码。如果您的按钮正在执行更改布局或添加/删除某些内容的操作,那么在客户端执行它会更有效,因此它们的资源会被占用而不是服务器。

[HTML]<form name=frm action="" method="post">
<table>
<tr><td><select name=combo>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<td><input type="text" name=tb1 value=""></td>
<td><input type="text" name=tb2 value=""></td>
<td><input type="text" name=tb3 value=""></td>
</tr>
<input type="submit" name=submit value=AddRow>
</table>
</form>[/HTML]
Hi all .Here is the code for a simple html design .All the controls here are in a single line.
In addition to that ,there is a submit button
Well my real problem starts now.
What iam supposed to do is to write some code such that
each time on clicking of AddRow button a new row with all those controls is generated.
For example,on clicking the button first time ,one such row is generated with a List/Menu Box,and three text boxes.
On next click i have another such row and in all two rows.
On third click i have three such rows and so on.
All this is to be done in php. I have some idea but that is not worthy enough to be implemented.
I am making some increment function in javascript to be called on the onclick eventof the addrow button.
Though its not of much help,so if any one can help me out,You are most welcome.Please go ahead

Thanks and rergards
TechnoAtif

解决方案

Is it paramount it is to be done in PHP?

I mean, just using javascript would mean there are no new page requests and, therefore, less resources consumed.

Regards.


Hi markusn,
Thanks for such quick response.If it is possible whole and sole in javascript ,then also it is of much help ,atleast i would be able to get the concept behind it.However if it could be done using php ,it could be better for me.But no problem if its in javascript.

Thanks and Regards
TechnoAtif


Yeah, I am thinking you need javascript. Or AJAX would be better. But to expand a bit on markus''s post, my apologies if you already know this, just worth making sure we''re on the same page!

php is server side, so to regenerate code using php, you would need to request the page again, which usually means refreshing the page. Javascript is client side which means that it can change the code without refreshing (simplified). If your buttons are doing something like changing the layout, or adding/removing something, it''d be more efficient to do it on the client side so it''s their resources that are taken up rather than your servers.


这篇关于在每个按钮单击上添加具有多个控件的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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