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:

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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -