How To Pass Php In Javascript, The Autocomplete(autosuggestion) In The Dynamically Add?
sorry for bad english. so i want try make to dynamically add an new input field on key down with using autocompelete(auto suggestion) for evey new dynamically add. so every add an
Solution 1:
$code1=""; is after the if condition so whatever the value is coming from post it in $code1 = isset($_POST['code']) ? $_POST['code1'] : '';
it will again assigned at the end $code = "";
which make it empty every time.
So do it like this
<?php$code1="";
if($_GET) {
$code1 = isset($_POST['code']) ? $_POST['code1'] : '';
$descrip = isset($_POST['descrip1']) ? $_POST['descrip1'] : '';
$color = isset($_POST['color1']) ? $_POST['color1'] : '';
$type = isset($_POST['type1']) ? $_POST['type1'] : '';
$qty = isset($_POST['qty1']) ? $_POST['qty1'] : '';
}
?>
now it first asign velue "" to $code1 and if $_GET has value new value is been assigned to it
or you can add else and put it in there
Solution 2:
Try using a session + ajax. I'm not 100% sure if it will suit your needs or not:
page1.php
<?php
session_start(); ?><html><head><metahttp-equiv="Content-Type"content="text/html; charset=utf-8" /><title>Admin</title><linkhref="css/inputpo.css"rel="stylesheet"><linkrel="stylesheet"href="css/jquery-ui.css"/><scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script></head><body><h1>Form</h1><formmethod = "POST"action="text.php"id="masterform"><divid="adder">Add</div><divid="delete">Clear</div><divid="loader"></div><inputid="go"name=""type="submit" /></form><scripttype="text/javascript">functionAddFormRow(IdElem,Func)
{
$("#"+IdElem).html("Loading...");
if(Func == 1)
Qfunc = 'command=true';
if(Func == 0)
Qfunc = 'command=false';
$.ajax({
url: "page2.php?"+Qfunc,
cache: false,
success: function(result) {
$("#"+IdElem).html(result);
}
});
}
$(document).ready(function(){
AddFormRow('loader',1);
$("#adder").click(function() {
AddFormRow('loader',1);
});
$("#delete").click(function() {
AddFormRow('loader',0);
});
});
</script></body></html>
page2.php
<?php
error_reporting(E_ALL);
session_start();
if(isset($_GET['command']) && $_GET['command'] !== 'true')
unset($_SESSION['myform']);
$_SESSION['myform'][] = 1;
for($i = 0; $i < count($_SESSION['myform']); $i++) { ?><tableheight="51"border="0"cellspacing="2"><tr><tdwidth="99"align="center"labelfor="suggestionbox"><divalign="center">Code Product</div></label></td><td><divalign="center">Description <?phpecho$i; ?></div></td><td><divalign="center">Type <?phpecho$i; ?></div></td><td><divalign="center">Color <?phpecho$i; ?></div></td></tr><tr><td><inputclass="last"type="text"id="code<?phpecho$i; ?>"name='code<?phpecho$i; ?>'value="code<?phpecho$i; ?>"></td><td><inputclass="last"type="text"id="descrip<?phpecho$i; ?>"name='descrip<?phpecho$i; ?>'value=""></td><td><inputclass="last"type="text"id="type<?phpecho$i; ?>"name='type<?phpecho$i; ?>'value=""></td><td><inputclass="last"type="text"id="color<?phpecho$i; ?>"name='color<?phpecho$i; ?>'value=""></td></tr></table><?php } ?>
Post a Comment for "How To Pass Php In Javascript, The Autocomplete(autosuggestion) In The Dynamically Add?"