我需要一些能简化我工作的东西。我正在考虑只有一个基于HTML的表单,在那里我可以输入数据,并通过点击一个按钮,让我有一个代码来显示命令,我应该能够复制它。
不幸的是,我在下面尝试的警报不起作用。
<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>
发布于 2019-03-25 12:45:28
你可以试试这个:
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");
}#copy {
height: 300px;
width: 500px;
}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>
https://stackoverflow.com/questions/55331234
复制相似问题