【问题标题】:Dependent form fields Issue相关表单字段问题
【发布时间】:2017-01-12 11:01:23
【问题描述】:

需要知道表单域的名称是什么?当用户点击检查复选框时创建?

<html>
<head>
<title>Sample from PHP Server File Uploader Script</title>

<!––Script for Checkbox new Filename field––>
    <script type="text/javascript">
 function dynInput(cbox) {
  if (cbox.checked) {
    var input = document.createElement("input");
    input.type = "text";
    var div = document.createElement("div");
    div.id = cbox.name;
    div.innerHTML = "Enter New File Name here";
    div.appendChild(input);
    document.getElementById("insertinputs").appendChild(div);
  } else {
    document.getElementById(cbox.name).remove();
  }
}
</script>    
<!--End of Script for Checkbox new Filename field-->

</head>
<form method="post">
<strong>Enter Direct File URL:<br></strong>
<input name="url" size="50" /><br><br>
<strong>File name:<br></strong>
<input type="checkbox" name="Leech" onclick="dynInput(this);"> Use Different Filename?
<!--Position for New filename field-->
<p name= "filename" id="insertinputs"></p>
<input name="submit" type="submit" />
</form>

我是编码新手! 我在哪里尝试为服务器创建远程 URL PHP 文件上传器!

我现在差不多完成了,我正在添加更多代码,以便用户也可以自定义文件名! 任何帮助将不胜感激!

PHP Server File uploader查看工作代码

【问题讨论】:

    标签: javascript php jquery html cpanel


    【解决方案1】:

    我认为您正在寻找这个: 将此代码放在此行的下方:

     var input = document.createElement("input");
     input.setAttribute('name',   'new_attribute');
    

    【讨论】:

    • @Arjun :如果您发现答案有用,请标记绿色勾号 :)
    猜你喜欢
    • 1970-01-01
    • 2013-04-18
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 2016-05-23
    • 2015-12-15
    相关资源
    最近更新 更多