2015-09-30 48 views
0

2頁的index.php和function.php如何從一個頁面轉院輸入自動完成的值到另一個頁面像值=「<?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> 

和關於頁面index.php頁面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> 
    '; 
?> 

,我有自動完成,我選擇了價值從<input type = "text" name = "skill" id = "skill" />

如何輸入(的index.php)<input type = "text" name = "skill" id = "skill" />的選擇的值傳遞給頁面function.php到<input type = "text" name = "skill" value = "chosen value from autocomplete (index.php)" />

這樣<input type = "text" name = "skill" value = "<?php value autocomplete ?>" />

+0

你什麼時候調用function.php? – QBernard

回答

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>'; 
?> 
+0

感謝您的回覆,在我需要的值這個」/> – Max

相關問題