不要在浏览器中打开消息框,而是将值发送到文本栏
Instead of opening a message box in the browser, send the value to the text bar
当我打开盒子并且select一个值:
它在浏览器的消息框中传递相应的link:
我想要这个值而不是出现在消息框中,它会出现在文本栏中,我需要修改或添加哪一行代码才能使最终结果发生变化?
预期结果:
我的脚本:
<html>
<head>
<title></title>
</head>
<body>
<input type="text" name="url1" id="url1" style="width: 283px;" />
<script src="http://d3js.org/d3.v3.js"></script>
<script>
d3.csv("Lista_de_Jogos.csv", function(error, data) {
var select = d3.select("body")
.append("div")
.append("select")
select
.on("change", function(d) {
var value = d3.select(this).property("value");
alert(value);
});
select.selectAll("option")
.data(data)
.enter()
.append("option")
.attr("value", function (d) { return d.value; })
.text(function (d) { return d.label; });
});
</script>
</body>
</html>
删除行 alert(value);
。
并附加此代码
document.querySelector('#url1').value=value
这应该有效;
当我打开盒子并且select一个值:
它在浏览器的消息框中传递相应的link:
我想要这个值而不是出现在消息框中,它会出现在文本栏中,我需要修改或添加哪一行代码才能使最终结果发生变化?
预期结果:
我的脚本:
<html>
<head>
<title></title>
</head>
<body>
<input type="text" name="url1" id="url1" style="width: 283px;" />
<script src="http://d3js.org/d3.v3.js"></script>
<script>
d3.csv("Lista_de_Jogos.csv", function(error, data) {
var select = d3.select("body")
.append("div")
.append("select")
select
.on("change", function(d) {
var value = d3.select(this).property("value");
alert(value);
});
select.selectAll("option")
.data(data)
.enter()
.append("option")
.attr("value", function (d) { return d.value; })
.text(function (d) { return d.label; });
});
</script>
</body>
</html>
删除行 alert(value);
。
并附加此代码
document.querySelector('#url1').value=value
这应该有效;