javascript - how to tranfer the value of input autocomplete from one page to another page like value = "<?php value autocomplete ?>" -
this question has answer here:
- how pass javascript variables php? 12 answers
2 pages index.php , function.php
how transfer chosen value of input
like
<input type = "text" name = "skill" value = "<?php value autocomplete ?>" />
on page
index.php
there code
<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>
and on page 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 autocomplete" /> </div> ... </form> </div> '; ?>
on page index.php, have autocomplete, chose value <input type = "text" name = "skill" id = "skill" />
how transfer chosen value of input (index.php) <input type = "text" name = "skill" id = "skill" />
page function.php <input type = "text" name = "skill" value = "chosen value autocomplete (index.php)" />
like
<input type = "text" name = "skill" value = "<?php value autocomplete ?>" />
you can use ajax post value there have with:
$("#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 data if returns anything. }); } });
now in 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>'; ?>
Comments
Post a Comment