2页index.php和function.php
如何传输所选的输入值
喜欢这个
<input type = "text" name = "skill" value = "<?php value autocomplete ?>" />
页面
的index.php
有这段代码
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript">
$().ready(function() {
$("#skill").autocomplete("get_list.php", {
width: 260,
matchContains: true
});
});
</script>
</head>
<body>
<input type="text" name="skill" id="skill" />
</body>
</html>
和页面上的function.php
<?php
$form = '
<div name="input" class="input_box" id="input">
<form action="function.php" target="iframe" enctype="multipart/form-data" method="post" >
....
<div style="padding-right: 14px;">
<input type="text" name="skill" value="value from autocomplete" />
</div>
...
</form>
</div>
';
?>
在页面index.php上,我有自动完成功能,我从<input type = "text" name = "skill" id = "skill" />
中选择了值
如何将所选的输入值(index.php)<input type = "text" name = "skill" id = "skill" />
传递给page.php到<input type = "text" name = "skill" value = "chosen value from autocomplete (index.php)" />
喜欢这个
<input type = "text" name = "skill" value = "<?php value autocomplete ?>" />
答案 0 :(得分:0)
您可以使用ajax在那里发布值,但必须使用:
$("#skill").autocomplete("get_list.php", {
width: 260,
matchContains: true,
select: function( event, ui ) {
$.post('path/to/function.php', {"selected":ui.value}, function(data){
console.log(data); // check the data if returns anything.
});
}
});
现在在function.php
:
<?php
$form = '<div name="input" class="input_box" id="input">'.
.........
'<input type="text" name="skill"' .
'value="'.isset($_POST['selected']) ? $_POST['selected'] : 'default text' . '" />';
</div>
...
</form>
</div>';
?>