首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何创建一个简单的HTML,允许我输入数据,并在以后提出一个我可以复制的命令?

我如何创建一个简单的HTML,允许我输入数据,并在以后提出一个我可以复制的命令?
EN

Stack Overflow用户
提问于 2019-03-25 12:22:10
回答 1查看 29关注 0票数 0

我需要一些能简化我工作的东西。我正在考虑只有一个基于HTML的表单,在那里我可以输入数据,并通过点击一个按钮,让我有一个代码来显示命令,我应该能够复制它。

不幸的是,我在下面尝试的警报不起作用。

代码语言:javascript
复制
<html>
<head>
 <script type="text/javascript">
 function ExampleJS(){
    var LDAPGroupOU = document.getElementById("ldap").value;
    var poolmin = document.getElementById("pmin").value;
    var poolmax = document.getElementById("pmax").value;
    alert("ip local pool " + LDAPGroupOU + "-pool" + " " + poolmin + "-" + poolmax + " " + "mask 255.255.255.255" + "\n" + "tunnel-group " +  LDAPGroupOU + "-profile type remote-access" + "\n" + "tunnel-group " +  LDAPGroupOU + "-profile general-attributes" + "\n" + "  address-pool " + LDAPGroupOU + "-pool" + "\n" + "  authentication-server-group RADIUS" + "\n" + "tunnel-group " + LDAPGroupOU + "-profile webvpn-attributes" + "\n" + "authentication aaa certificate" + "\n" + "pre-fill-username ssl-client" + "\n" + "exit" + "\n" + "crypto ca certificate map" + " " + LDAPGroupOU + "-map 10" + "\n" + "  subject-name attr ou eq " + LDAPGroupOU+ "\n" + "exit" + "\n" + "webvpn" + "\n" + "certificate-group-map " + LDAPGroupOU + "-map 10 " + " " + LDAPGroupOU + "-profile" + "\n" + "end"  + "\n" + "wr" );
 }
 </script>

</head>
<body>
    <FORM NAME="myform" onSubmit="JavaScript:ExampleJS()">
            xCVPN Code Generator <br />
            <br />
         Customer LDAP Group: <input type="text" id="ldap" name="firstname" /><br />
         Minimum Pool:  <input type="text" id="pmin" name="lastname" /><br />
         Maximum Pool:  <input type="text" id="pmax" name="lastname" /><br />
        <input name="Submit"  type="submit" value="Generate" />
    </FORM>
</body>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-25 12:45:28

你可以试试这个:

代码语言:javascript
复制
function ExampleJS() {
  var LDAPGroupOU = document.getElementById("ldap").value;
  var poolmin = document.getElementById("pmin").value;
  var poolmax = document.getElementById("pmax").value;
  var copy = document.getElementById("copy");
  copy.textContent = "ip local pool " + LDAPGroupOU + "-pool" + " " + poolmin + "-" + poolmax + " " + "mask 255.255.255.255" + "\n" + "tunnel-group " + LDAPGroupOU + "-profile type remote-access" + "\n" + "tunnel-group " + LDAPGroupOU + "-profile general-attributes" + "\n" + "  address-pool " + LDAPGroupOU + "-pool" + "\n" + "  authentication-server-group RADIUS" + "\n" + "tunnel-group " + LDAPGroupOU + "-profile webvpn-attributes" + "\n" + "authentication aaa certificate" + "\n" + "pre-fill-username ssl-client" + "\n" + "exit" + "\n" + "crypto ca certificate map" + " " + LDAPGroupOU + "-map 10" + "\n" + "  subject-name attr ou eq " + LDAPGroupOU + "\n" + "exit" + "\n" + "webvpn" + "\n" + "certificate-group-map " + LDAPGroupOU + "-map 10 " + " " + LDAPGroupOU + "-profile" + "\n" + "end" + "\n" + "wr";
  copy.select();

  /* Copy the text inside the text field */
  document.execCommand("copy");
}
代码语言:javascript
复制
#copy {
  height: 300px;
  width: 500px;
}
代码语言:javascript
复制
xCVPN Code Generator <br />
<br /> Customer LDAP Group: <input type="text" id="ldap" name="firstname" /><br /> Minimum Pool: <input type="text" id="pmin" name="lastname" /><br /> Maximum Pool: <input type="text" id="pmax" name="lastname" /><br />
<input name="Submit" type="button" onClick="ExampleJS()" value="Generate" />
<br />
<textarea id="copy"></textarea>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55331234

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档