[英]How to place a posted value in a textbox
Here in click.html,OnClick of clint_ip text box is redirecting to index.html.There we will select some client_ip's .After hitting the submit button in the index.html,I'm able to retrieve the values in the click.html.But I'm unable to keep the retrieved value into the client_ip textbox of click.html.I'm able to get the values in the "res" variable. 在click.html中,clint_ip文本框的OnClick重定向到index.html。我们将选择一些client_ip。在单击index.html中的Submit按钮之后,我可以在click.html中检索值。但是我无法将检索到的值保留在click.html的client_ip文本框中。我能够在“ res”变量中获取值。
My click.html 我的click.html
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/mpryvkin/Plugins/master/pagination/simple_numbers_no_ellipses.js"></script>
<link rel='stylesheet' href='style.css'>
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css">
</head>
<body>
<div id="clicDiv">
Client IP :<input type="text" id="ipClick" onclick="getValue();" name="Client IP" />
</div>
<script>
function getUSERIP(){
if(!window.location.href.match(/client_ip=.*?([^\&])/))
return;
var ip = window.location.href.match(/client_ip=.*?([^\&])/)[0].replace('client_ip=','');
$("#ipClick").val(ip);
}
getUSERIP();
function getValue(){
location.href='/home/divya/html_docs/index.html';
}
</script>
</body>
</html>
My index.html: 我的index.html:
<!DOCTYPE html>
<meta charset='utf-8'>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/mpryvkin/Plugins/master/pagination/simple_numbers_no_ellipses.js"></script>
<link rel='stylesheet' href='style.css'>
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css">
<script>
$(document).ready(function() {
$("#ip").val('');
$('#example').DataTable( {
"pagingType": "full_numbers"
} );
} );
</script>
</head>
<body>
<div>
<form action="/home/divya/html_docs/click.html" method="get" >
Client_ip :<input type="text" id ="ip" name="client_ip" style="width: 600px;"/>
<div id="subDiv">
<button type="submit" value="Submit">Submit</button>
</div>
</div></br>
<table id="example" class="display" cellspacing="0" width="100%">
</table>
<script>
var tabulate = function (data,columns) {
var svg = d3.select('#ip').append("svg")
var table = d3.select('#example')
var thead = table.append('thead')
var tbody = table.append('tbody')
thead.append('tr')
.selectAll('th')
.data(columns)
.enter()
.append('th')
.text(function (d) { return d })
var rows = tbody.selectAll('tr')
.data(data)
.enter()
.append('tr')
var cells = rows.selectAll('td')
.data(function(row) {
return columns.map(function (column) {
return { column: column, value: row[column] }
})
})
.enter()
.append('td')
.text(function (d) { return d.value })
.append("input")
.attr("id","change")
.attr("type", "checkbox")
.style("float","left")
.on("click", function(d,i) {
var csv = $(':checkbox[id=change]:checked').map(function(){return $(this).parent().text();}).get().join(',');
$('#ip').val(csv);
});
return table;
}
d3.csv('some1.csv',function (data) {
var columns = ['client_ip']
tabulate(data,columns)
});
</script>
</body>
</html>
Can anyone please help me out regarding this issue ... 谁能帮我解决这个问题...
在您的getValue()函数中,您需要返回res值。
You make a function for it and put this on click.html file 您为此创建一个函数,并将其放在click.html文件中
function getUSERIP(){
if(!window.location.href.match(/client_ip=.*?([^\&]+)/))
return;
var ip = window.location.href.match(/client_ip=.*?([^\&]+)/)[0].replace('client_ip=','');
$("#ipClick").val(ip);
}
getUSERIP();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.