Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用下拉菜单打开新的框架/窗口_Javascript_Html_Drop Down Menu - Fatal编程技术网

Javascript 如何使用下拉菜单打开新的框架/窗口

Javascript 如何使用下拉菜单打开新的框架/窗口,javascript,html,drop-down-menu,Javascript,Html,Drop Down Menu,单击“创建节点”按钮时,如何打开新的框架或窗口?我希望新的框架包含一个文本字段和下拉菜单,以便用户可以选择一个选项 <form> <html> <body> <button onclick="myFunction()">Create node</button><br> <br> <button onclick="myFunction()">Search node</button>

单击“创建节点”按钮时,如何打开新的框架或窗口?我希望新的框架包含一个文本字段和下拉菜单,以便用户可以选择一个选项

<form>
<html>
<body>
  <button onclick="myFunction()">Create node</button><br>
  <br>
  <button onclick="myFunction()">Search node</button><br>
  <br>
  <button onclick="myFunction()">Create Realationship</button><br>
</body>
</html>
</form>

创建节点

搜索节点

创建关系
从上面的代码中,我可以创建并单击按钮,但我无法创建新框架,我不知道如何为用户提供选择选项。

我想您的意思是:

var myFunction = function() {
   //create some html elements with the createElement function
    var select = document.createElement("select"),
        input = document.createElement("input");
    var head = document.createElement("h2");
    var option1 = document.createElement("option");
    var option2 = document.createElement("option");

    //change the content of elements
    head.innerHTML = "select and edit option";

    option1.innerHTML = "option 1";
    option2.innerHTML = "option 2";
    //you can add an element to another element with element.appendChild("new child element here")

    select.appendChild(option1);
    select.appendChild(option2);

    //you can set all attributes with element.setAttribute("attribute name", "attribute value")
    input.setAttribute("type", "text");

    //open a window, with no url and a specified width and height
    var w = window.open('', "", "width=600, height=400, scrollbars=yes");

    //again add children elements, but now insert them to the created window which is stored in the 'w' variable (note that it does not replaces the document, it only means that you represent another window)
    w.document.body.appendChild(head);
    w.document.body.appendChild(select);
    w.document.body.appendChild(input);
}
在这里拉小提琴:

您也可以加载预定义的url,但很难使其动态化


我希望这对您有所帮助。

从您的代码开始是不合适的<代码>应该在正文中创建,并且
应该是文档中的第一个标记。接下来,如果我理解正确,您只需在单击任何按钮后创建一个新窗口

您只需创建一个名为
myFunction
的函数,并传入
window.open('http://google.com)
将其删除。你可以在那里使用任何你想要的url,因此如果你的网站是
http://example.com
您可以在
http://example.com/node1.html
然后您将更改
窗口。打开('http://google.com)
窗口。打开('http://example.com/node1.html
)`


函数myFunction(){
窗口打开(“http://google.com");
}
创建节点

您能告诉我们您尝试过什么吗?我想知道如何打开框架或窗口并添加一些按钮和文本字段。。我一直尝试创建一个按钮并单击它,但无法执行下一个选项…是否可以在
标记之外放置一个表单?谢谢,这很有效,但我需要在新窗口中,为用户选择一个带有标签(请选择其中的节点和选项)的下拉列表和一个文本框(请输入属性)在用户可以输入属性和提交行的地方,这将打开一个新窗口。。现在,我如何在新窗口中添加一些文本框和下拉菜单它已经创建了一个文本框和一个下拉菜单(请参见fiddle演示)我有3个按钮1.创建节点我在这里有你的代码2.创建关系3.搜索关系,但在这里,如果我单击任何按钮,则会运行相同的代码。。如何根据单击的按钮过滤代码由于所有代码几乎相同,因此在调用函数f.e.myFunction(“1”)时使用标识符,然后运行稍有不同的代码(此处演示:)是的,这起作用了,我如何在同一新窗口中有多个下拉框和文本框?
<html>

    <head>

    </head>
<body>

<script>
    function myFunction() {
        window.open("http://google.com");
    }
</script>

<button onclick="myFunction()">Create Node</button>

</body>


</html>