如何将多个文本字段输出到一页 [英] How can I output multiple text fields to one page

查看:82
本文介绍了如何将多个文本字段输出到一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作要求使用许多模板来向其他部门提交信息.为了避免使用6个不同的模板,我想创建一个统一的简单html文档,该文档使我可以在需要信息的简单文本字段中键入内容,然后将该信息输出到同一页面上的另一个字段或打开一个新字段完全翻页.

My job requres the use of a lot of templates to be used for submitting information to other departments. To avoid having 6 different templates to go off of, I wanted to create a unified simple html document that would allow me to type in simple text fields where information is needed then output that information to another field either on the same page or open a new page completely.

例如:

<SPAN ID="copytext">
<b>**TOC Template**</b>
<br />
<br />
TOC,
<br />
<br />
Subscribers Impacted: <input type="text" id="text1" placeholder="How many"><br>
Business Name(s): <input type="text" id="text2" placeholder="Name of the business"><br>
Site ID: <input type="text" id="text3" placeholder="Site ID from Granite"><br>
</span>

<TEXTAREA ID="holdtext" STYLE="display:none;">
</TEXTAREA>
<BUTTON onClick="myFunction(); ClipBoard();">Copy to Clipboard</BUTTON> 
<script>
function myFunction() {
    document.getElementById("firstName").select();
}
</script>

<SCRIPT LANGUAGE="JavaScript">

function ClipBoard()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
}

</SCRIPT>

我希望能够单击该按钮,然后将其输出或复制页面上的所有信息(包括文本字段内的内容),以便将其粘贴到我们的票务系统中.任何帮助将不胜感激!如果我可以复制它,那将是最简单的,但是如果我需要将其输出到同一页上的另一张纸上,那也可以.

I want to be able to click the button and just have it output or copy all of the information on the page including what is inside the text fields so that I can just paste it in our ticketing system. Any help would be greatly appreciated! If I can get it to copy that would be the easiest, but if I need to output it on to a separate on the same page, that would work too.

编辑

这就是我要找的东西:

Subscribers Impacted: <input type="text" id="text1" placeholder="How many">        <br>
Business Name(s): <input type="text" id="text2" placeholder="Name of the         business"><br>
Site ID: <input type="text" id="text3" placeholder="Site ID from Granite"><br>

*这些将在其旁边有文本字段.填写完这些内容后,我想将所有字段输出到另一个页面,该页面将所有内容填充到我可以复制所有内容的位置.

*These would have the text fields beside them. Once I fill them in, I wanted to output all of the fields to another page that would have everything filled in to where I could just copy it all.

它看起来像这样:

Subscribers Impacted: One
Business Name: Mcdonalds
Site ID: GXQ9715

我目前拥有的是一个上面有几个DIV的网页,当我单击模板链接时,它将使用该模板加载html页面.我只希望能够填写它,单击提交",然后将其输出到没有文本字段的另一页.

What I have currently is a web page with a few DIVs on it and when I click the link to a template, it loads the html page with the template. I just want to be able to fill it out, hit submit then have it output to another page without the text fields.

推荐答案

您需要将JavaScript与html一起使用.这是一个示例

You need to use JavaScript with html. Here is an example

    <script>
        $(function () {
        $("#NameField").change(function () {
                        document.getElementById("NameBox").value = $("#NameField").val();

                    });
                    $("#NameField").keyup(function () {
                    document.getElementById("TheWord").value = $("#NameField").val().toUpperCase();});
        });
        </script>


    <input type="text" class="CustomWord" id="NameField" onkeydown="return alphaOnly(event);" name="NameField" value="Write Here" onfocus="if (this.value == 'Write Here') this.value = '';" onblur="    if (this.value == '') this.value = 'Write Here';"> 

<label for="TheWord">Word: </label><input readonly="readonly" id="TheWord" /><br />

基本上,创建您的文本字段并为每个文本字段指定一个ID,然后在这些文本字段中的任何一个发生更改时使用JavaScript进行操作.例如,如果ID为blahText1的textbox1更改,则将字符串复制到lable1或将文本复制到隐藏字段.

Basically, create your textfields and give each one an ID and then use JavaScript to do things if any of these textfields changes. Something like, if textbox1 with ID blahText1 change, copy the string to lable1 or copy the text to hidden field.

这篇关于如何将多个文本字段输出到一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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