I want to have multiple drop down lists that perform a search in the database and echo the information in a table on the webpage.
From tutorials I have managed this, but only for one select choice. I am struggling to make the second drop down list refine the search conditions.
Drop down list 1 should be the option that searches the database for the selected value.
Drop down list 2 should add an AND condition to the sql and uses the second value to refine the search.
The code below does not pull any info from the database on change. If I remove the AND statement it will pull information from the database.
HTML:
<!DOCTYPE html>
<html>
<head>
<title> Vault of Faults-Fault Search </title>
<link rel="stylesheet" type="text/css" href="mystyle1.css">
<script src="dropdownfix1.js"></script>
</head>
<body>
<div id=container>
<div id=header>
<div id=headdiv>
<form id=login name="login" action="login.php" method="post">
<fieldset class="field_set">
<legend>Administrator Login:</legend> <!-- legeng tage creates a header title for the fieldset box, filedset pulls all data in the tag to gether with a box around it. -->
UserName: <input type="text" name="username"> <br>
Password:<br> <input type="password" name="password"> <br>
<input type="submit" value="Login"> <input type="Button" onClick="parent.location='addafix.php'" Value="Add a Fix">
</fieldset>
</form>
</div>
</div>
<div id=content>
<div id=maincontent>
<div id=select>
<form>
<fieldset class="field_set2">
<legend>Quicklink Vault of Faults Search</legend>
Product:
<select name="Product" onchange="showUser(this.value)">
<option value="0">Select Product</option>
<option value="1">Merlin</option>
<option value="2">Encoder</option>
<option value="3">Mac Live</option>
<option value="4">Windows Live</option>
<option value="5">Windows S&F</option>
<option value="6">Mac S&F</option>
</select>
<select name="Product_Issue" onchange="showIssue(this.value)">
<option value="0">Select Issue</option>
<option value="1">Preview</option>
<option value="2">Live Reciever</option>
<option value="3">Mac Live</option>
<option value="4">Windows Live</option>
<option value="5">Windows S&F</option>
<option value="6">Mac S&F</option>
</select>
<input type="submit" value="Search">
</fieldset>
</form>
</div>
<div id=list>
<div id="txtHint"><b>Person info will be listed here.</b></div>
</div>
</div>
</div>
</div>
</body>
</html>
JavaScript:
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
function showIssue(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?p="+str,true);
xmlhttp.send();
}
PHP:
<?php
$q=$_GET["q"];
$p=$_GET["p"];
require 'connection.php';
mysqli_select_db($con,"Faults" );
//where statement in the sql syntax will select where in db to get infor, use AND to add another condition
$sql="SELECT Products.Product_Name, Versions.Version, Platform.Platform_Name, Issues.Issue, Issues.Sub_Issue, Issues.Fix
FROM Solutions INNER JOIN Products ON Solutions.Product = Products.Product_id
INNER JOIN Versions ON Solutions.Product_Version = Versions.Version_id
INNER JOIN Platform ON Solutions.Product_Platform = Platform.Platform_id
INNER JOIN Issues ON Solutions.Product_Issue = Issues.Issue_id
WHERE Product = '".$q."' AND Product_Issue = '".$p."'";
$result = mysqli_query($con,$sql);
//below is the echo statment to create the results in a table format, list collumn titles
echo "<table id=tables border='1'>
<tr>
<th>Products</th>
<th>Version</th>
<th>Platform</th>
<th>Issue</th>
<th>Sub Issue</th>
<th>Fix</th>
</tr>";
//below is script to list reults in a table format, $row [row name on table]
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Product_Name'] . "</td>";
echo "<td>" . $row['Version'] . "</td>";
echo "<td>" . $row['Platform_Name'] . "</td>";
echo "<td>" . $row['Issue'] . "</td>";
echo "<td>" . $row['Sub_Issue'] . "</td>";
echo "<td>Fix</td>";
echo "</tr>";
}
echo "</table>";
// below closes the coonection to mysql
?>
I think you need to concat the values of the dropdownlist. Something like:
<script type="text/javascript">
function server(aform)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+ product.value +"&" +"p="+product_i.value ,true);
xmlhttp.send();
}
</script>
Related
Hi i got 2 dropdown list (client and product) and 1 content data. The product dropdown list is depended from the choice in client dropdown list (i've already done that). The problem is i want the content data is autoloaded depend on the choice in product dropdown list.
Here is my code:
<script>
function filterClient(str) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("ProductOpt").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","filter_client.php?f=client&q="+str,true);
xmlhttp.send();
}
function filterProduct(str) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("content").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","filter_product.php?f=product&k="+str,true);
xmlhttp.send();
}
</script>
<table border='0' style='float: right'>
<tr>
<td>
<form>
<select name='ClientFilter' onchange="filterClient(this.value);">
<option value='0' style="text-align: center">--Filter by Client--</option>
<?php
$clientDL = mysql_query("SELECT * FROM `Client`");
while($client=mysql_fetch_array($clientDL))
echo "<option value='".$client['ClientID']."'>".$client['ClientName']."</option>";
?>
</select>
</form>
</td>
<td>
<form>
<select name='ProductFilter' id="ProductOpt" onchange="filterProduct(this.value);">
<option value='' style="text-align: center">--Filter by Product--</option>
</select>
</form>
</td>
</tr>
</table>
<div id="content"></div>
filter_client.php:
<?php
if (file_exists("../../../../wp-load.php")) {
require_once("../../../../wp-load.php");
}
$k = $_GET['k'];
global $dbhandle;//Database connection
if($q!=0) {
if (isset($_GET['f']) && $_GET['f'] == 'client') {
$productDL = mysql_query("SELECT * FROM `Product` where ProductID = " . $k);
while ($product = mysql_fetch_array($productDL))
echo "<option value='" . $product['ProductID'] . "'>" . $product['ProductName'] . "</option>";
}
}
?>
filter_product.php:
<?php
if (file_exists("../../../../wp-load.php")) {
require_once("../../../../wp-load.php");
}
$q = $_GET['k'];
global $dbhandle;//Database connection
if(isset($_GET['f'])&&$_GET['f']=='product'){
$result = mysql_query("SELECT * from `Invoice` WHERE ProductID= ".$k);
}
$list_Client = array();
while($row=mysql_fetch_object($result)){
$list_Client[] = $row;
}
// Load data from db and show it in div id = content
?>
I am working on a project at the moment. In iI am using ajax to update and calculate scores, which works fine. However, I have a color scheme that changes according to the score. The color does change, but only after the page is refreshed. Is there anyway I can get the color to change with refreshing the page?
Here is the code that I am using to assign colors:
<?php $row_class = "";
while($row = mysql_fetch_assoc($dbResult1))
{
if($row['total_mai'] <= 2)
$row_class = "success";
else if($row['total_mai'] >= 5)
$row_class = "danger";
else if($row['total_mai'] >= 3 and $row['total_mai'] < 5)
$row_class = "warning";
// echo $row_class;
?>
In another page, here is an example of one question, it has three answers and depending on the answer a color is assigned based on the score
<tr>
<td class="form-group col-md-6">Is the duration of therapy acceptable?</td>
<td class="form-group col-md-6">
<p class="radio-inline">
<input type="radio" name="therapydur" id="j1" value="0" <?php echo $j1; ?> required onchange="ajaxFunction('therapydur','<?php echo $count; ?>','0','<?php echo $row['p_id']; ?>')">
A
</input></p>
<p class="radio-inline">
<input type="radio" name="therapydur" id="j2" value="0" <?php echo $j2; ?> required onchange="ajaxFunction('therapydur','<?php echo $count; ?>','0','<?php echo $row['p_id']; ?>')">
B
</input></p>
<p class="radio-inline">
<input type="radio" name="therapydur" id="j3" value="1" <?php echo $j3; ?> required onchange="ajaxFunction('therapydur','<?php echo $count; ?>','1','<?php echo $row['p_id']; ?>')">
C
</input></p>
</td>
</tr>
Here is the ajax from the same page:
<script language="javascript" type="text/javascript">
function ajaxFunction(title,id,val,p_id)
{
//alert("test");
//alert(id);
//alert(val);
//alert(title);
//alert(p_id);
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//alert(xmlhttp.responseText);
var resp = xmlhttp.responseText;
var split_v = resp.split("__");
//alert(split_v.length);
//alert(split_v[1]);
document.getElementById("ajaxDiv_"+id).innerHTML=split_v[0];
document.getElementById("ajaxTotal").innerHTML=split_v[1];
}
}
xmlhttp.open("GET","ajax_mai.php?pdr_id="+id+"&value="+val+"&title="+title+"&p_id="+p_id,true);
xmlhttp.send();
return true;
}
</script>
i am using database to populate the dorpdown lis. now when i select the option from the first dynamic populated drom down list i want to use it to populate another dropdown list and based on that selection third dromdown list.
Here's the code i am working on,
<html>
<?php
include './config.php';
?>
<head>
<meta charset="UTF-8">
<title></title>
<SCRIPT>
$(".dropdown").hide();
$("#testcasedata").on("change", function() {
$(".dropdown").hide();
var value = $("#testcasedata").val();
$("#dropdown" + value).show();
});
</script>
</head>
<body>
<form method="POST" action="createTestCase.php">
// This is the first dropdown list
// It will return testsuite_id in dropdownlist
<?php
$sqll="SELECT testsuite_id FROM assigned_testsuite_tester Where Tester_name = 'Pritesh'";
echo "<select class='form-control' name='testsuite'>";
echo "<option value=''>Select One</option>";
foreach ($conn->query($sqll) as $row){
echo '<option value="'.$row['testsuite_id'].'">'.$row['testsuite_id'].'</option>';
}
echo "</select>";
?>
<input type="submit" name="submit" />
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
//testsuite_id will be the input variable for the second dropdownlist
// the second dropdown list will populate with testcase_id.
$testsuite = filter_input(INPUT_POST, 'testsuite');
echo $testsuite;
if($testsuite != ''){
$sqll="SELECT Testcase_id FROM assigned_testsuite_testcase Where testsuite_id = '$testsuite'";
echo "<select name='testcasedata' id='testcasedata' >";
echo "<option value=''>Select One</option>";
foreach ($conn->query($sqll) as $row){
echo '<option value="'.$row['Testcase_id'].'">'.$row['Testcase_id'].'</option>';
}
echo "</select>";
}
// with use of test case id i am retrieving the Product_id
$testcase = filter_input(INPUT_POST, 'testcase');
$sqll="SELECT Product_id FROM Testcase_master Where Testcase_id = '$testcase'";
$productid='';
foreach ($conn->query($sqll) as $row){
$productid = $row['Product_id'];
}
//now product id must be the input for the third dropdownlist.
if($productid != ''){
$sqll="SELECT circle.circle_id,circle.Circle_name FROM circle INNER JOIN assigned_circle_product ON assigned_circle_product.`Product_id` = '$productid'";
echo "<select class='dropdown' name='circledata' id='circledata'>";
echo "<option value=''>Select One</option>";
foreach ($conn->query($sqll) as $row){
echo '<option value="'.$row['Circle_id'].'">'.$row['Circle_name'].'</option>';
}
echo "</select>";
}
}
?>
</body>
i was able to populate the first drop-down list and based on that populate the second drop-down list.but having problem for populating third one.
I was browsing through similar questions and find out that i need to use jquery/JavaScript to do that.I don't know that much about jquery but have inserted code for that too but still having problem to populating the third drop down list.
I am stuck at this point.Please give me some guidance.
I have been learning Javascript/Jquery and this is what i have done.
I don't know if it's a correct way or not. please look and tell me if i can do more to improve code.
First i have devided whole program into three seprate PHP files.
1.Main PHP File
<!DOCTYPE html>
<html>
<?php
include 'header.php';
include 'footer.php';
include './config.php';
?>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
function showCircle(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","GetProduct.php?q="+str,true);
xmlhttp.send();
}
function product1(str) {
str1 = document.getElementById("project");
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","GetTestcase.php?prod="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Add Circle to Product</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Select the circles where you want your product to test:
</div>
<div class="panel-body">
<div class="dataTable_wrapper">
<form action="circlrproduct.php" method="GET">
<div class="col-lg-6">
<div class="form-group">
<label>Project Name</label>
<?php
$sqll="SELECT Project_id,Project_title FROM project_master";
echo "<select class='form-control' name='project' onchange='showCircle(this.value)'>";
echo "<option value=''>Select One</option>";
foreach ($conn->query($sqll) as $row){
echo "<option value=$row[Project_id]>$row[Project_title]</option>";
}
echo "</select>";
?>
</div>
<div class="form-group">
<div id="txtHint"></div>
<!--<div id="txtHint1"></div>-->
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" name="submit" value="submit">Submit</button>
<button type="reset" class="btn btn-primary">Reset</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
First i select the project from the drop down list and at at the time of selection a ajax call will be made to get the product.
GetProduct.php
if(isset($_GET['q'])){
$q = (string)filter_input(INPUT_GET,'q');
}else{
// header('Location:AddCircleToProduct.php');
}
$sql2="SELECT Product_id,Product_title FROM product_master where Project_id = '$q'";
$support = $q;
$result = $conn -> query($sql2);
echo "<label>Product Name</label>";
echo "<select class='form-control' name='product' onchange='product1(this.value)'>";
echo "<option value=''>Select One</option>";
while ($row = mysqli_fetch_array($result)){
echo "<option value={$row['Product_id']}>{$row['Product_title']}</option>";
}
echo "</select>";
At the time of product selection one another call is made through Ajax to get the test case.
3.GET Test case
if(isset($_GET['prod'])){
$product = filter_input(INPUT_GET, 'prod');
$query = "select * from testcase_master where Product_id = '$product'";
//echo $query;
echo '<div class="panel-body"><div class="dataTable_wrapper"><table class="table table-striped table-bordered table-hover" id="dataTables-example"">';
echo '<thead><tr><th>SELECT</th><th>Testcase Id</th><th>Testcase Title</th><th>Description</th><th>Created by</th><th>Subscriber Type</th><th>Priority</th></tr></thead><tbody>';
if($results = $conn -> query($query) or die(mysqli_errno($conn))){
while ($row = mysqli_fetch_array($results)) {
echo '<tr class="odd gradeX">';
echo "<td><input type=\"checkbox\" name=\"checkbox[]\" id=\"checkbox[]\" value=\"".$row['Testcase_id']."\" class='form-control'/></td>";
echo "<td>{$row['Testcase_id']}</td><td>{$row['Testcase_title']}</td><td>{$row['Testcase_desc']}</td><td>{$row['Created_by']}</td><td>{$row['Subscriber_type']}</td><td>{$row['Priority']}</td>";
echo '</tr>';
}
echo '</tbody></table></div></div>';
} else {
echo 'ss' . mysqli_error($conn);
}
}
else{
echo'Sorry You cant access this page Directly.';
}
?>
After getting the list of test case selection of checkbox is made.
4.circledata.php
<?php
include './config.php';
if(isset($_GET['submit'])){
if(isset($_GET['checkbox'])){
if (is_array($_GET['checkbox'])) {
foreach($_GET['checkbox'] as $value){
$q1 = "INSERT INTO tmtool.assigned_circle_product (`Circle_id`, `Product_id`) VALUES ('.$value.','$_SESSION[prod]')";
if($conn -> query($q1) == TRUE){
echo "Data Entered successfully\n";
} else {
echo 'Error' . mysqli_error($conn);
}
}
} else {
$value = $_GET['checkbox'];
echo $value;
}
}
}
?>
And in the last file all the data are commited into the database.
Please tell me if anything i can do to improve my code.
Thank you.
The below code tries to change the Select option tag by making a Ajax call that connects to PHP on the server and retrieves data. However the below code works fine if i were to set the response text to a span tag but it does not work for Select option tag ?
<?php
$q = intval($_GET['q']);
$con=mysqli_connect("localhost","rot","ro","abc","3306");
/
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT DISTINCT(UniqueBusId) FROM cfv_busstopnames WHERE busnumber = ".$q." ");
if (!$result) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
while($row = mysqli_fetch_array($result))
{
echo "<option>" . $row['UniqueBusId'] . "</option>" ;
}
mysqli_close($con);
?>
.
<script>
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("select-choice-direction").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getdirection.php?q="+str.value,true);
xmlhttp.send();
}
</script>
<Body>
<label for="select-choice-direction">Direction</label>
<select name="select-choice-direction" id="select-choice-direction" data-native-menu="false" ">
<option> Direction heading towards?</option>
<option value="X">X</option>
<option value="Y">Y</option>
<!-- etc. -->
</select>
</Body>
Instead of
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("select-choice-direction").innerHTML=xmlhttp.responseText;
}
}
try
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
$('#select-choice-direction').html(xmlhttp.responseText).selectmenu( "refresh");
}
}
This tells jQuery Mobile to refresh the selectmenu widget (http://api.jquerymobile.com/selectmenu/#method-refresh)
DEMO
Im getting a set of values from the database to show in a drop down list. Once the user selected an item from the drop down list the selected item should be assigned to a SESSION variable. I tried this but yet it is not working. Please smeone help me to sort it out.
<select id="FormNameSelecting" style="position:absolute; width:300px; top:50px; left:200px; "><option></option>
<?php
$result = mysqli_query($con,"SELECT * FROM Form");
while($row = mysqli_fetch_array($result)){
echo "<option value='$row[Form_ID]'>$row[Form_Name]</option>";
echo
}
?>
</select>
So I need to store these values receive from $row[Form_ID] and $row[Form_Name] in 2 session variables named $_SESSION['Form_ID'] and $_SESSION['Form_Name']; Could someone explain me how I can assign the selected item's values to these two session variables.
The selected option element must have selected attribute.
You should try something like this:
<select id="FormNameSelecting" style="position:absolute; width:300px; top:50px; left:200px; ">
<?php
$result = mysqli_query($con,"SELECT * FROM Form");
while($row = mysqli_fetch_array($result))
{
echo "<option value='{$row['Form_ID']}'";
if($row['Form_ID'] == $_SESSION['Form_ID'])
echo " selected";
echo ">{$row['Form_Name']}</option>";
}
?>
</select>
UPDATE:
You can store it in $_SESSION after the form submit
<?php
session_start(); // dont forget it!
if(isset($_POST['submit']))
{
$_SESSION['Form_ID'] = $_POST['Form_ID'];
$_SESSION['Form_Name'] = $_POST['Form_Name'];
}
?>
Try This:
In your page add this and create one more page "showValues.php"(This is the page where you want to create and use your session variable).Code of showValues.php is also given below for example.
<html>
<head>
<script>
function showValue(vals)
{
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var val= xmlhttp.responseText;
document.getElementById("tbl").innerHTML+=val;
}
}
xmlhttp.open("GET","showValues.php?vals="+vals,true);
xmlhttp.send();
}
</script>
</head>
<body>
<table id="tbl">
<tr>
<td>
<select id="FormNameSelecting" style="position:absolute; width:300px; top:50px; left:200px; "><option></option>
<?php
$result = mysqli_query($con,"SELECT * FROM Form");
while($row = mysqli_fetch_array($result)){
echo "<option value='$row[Form_ID]'>$row[Form_Name]</option>";
echo
}
?>
</select>
</td>
</tr>
</table>
</body>
</html>
showValues.php
<?php
session_start();
$vals=$_REQUEST['vals'];
$_SESSION['SelectValue']=$vals;
echo $_SESSION['SelectValue'];
?>
try this
<form name="my_name" method="POST" action="">
<select name="FormNameSelecting" id="FormNameSelecting" style="position:absolute; width:300px; top:50px; left:200px; "> //don't forget put name at select
<option></option>
<?php
$result = mysqli_query($con,"SELECT * FROM Form");
while($row = mysqli_fetch_assoc($result)){ //prefer using assoc that array
echo "<option value='" . $row['Form_ID'] . ":::" . $row['Form_Name'] . "'>" . $row['Form_Name'] . "</option>";
}
?>
</select>
<input type="submit" name="go" value="go"/>
</form>
<?php
if(isset($_POST['go'])){
$store_sesi = explode(":::",$_POST['FormNameSelecting']);
$_SESSION['ID'] = $store[0];
$_SESSION['Name'] = $store[1];
}
?>
hope this code help you