• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

how to load values from form to jquery

am having 2 a select box with 2 options....

when i i select an option1 and click submit, i get values relating to the first option in the grid. But when i change to option2  the values does not change.

i need to refresh again and when i choose option2 this time i get the corresponding values and again when i try to change to option1 same prob as above.....pls help
<?
mysql_connect("localhost","root","");
mysql_select_db("lab")or die("CANNOT CONNECT To DATABASE".mysql_error());
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Flexigrid</title>
<link rel="stylesheet" type="text/css" href="css/flexigrid.css" />
<script type="text/javascript" src="jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="flexigrid.js"></script>
 
<script type="text/javascript">
 
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    } 
 
 
$(document).ready(function(){
 
$('form').submit(function() {
 
  var fname=$('#test_n').val();
	
	$("#flex1").flexigrid
			(
			{
			
			url: 'post2.php?type='+fname,
			dataType: 'json',
			colModel : [
			
				{display: 'Test ID', name : 'test_id', width : 40, sortable : true, align: 'center'},
				{display: 'Test Code', name : 'tst_code', width : 80, sortable : true, align: 'left'},
				{display: 'Test Name', name : 'test_name', width : 180, sortable : true, align: 'left'},
				{display: 'Test Dept ID', name : 'tst_dep_id', width : 70, sortable : true, align: 'center'},
				{display: 'Test Sample ID', name : 'tst_sample_id', width : 70, sortable : true, align: 'center' },//hide: true},
				{display: 'Normal Value', name : 'normal_val', width : 80, sortable : true, align: 'left',hide:true}
				//{display: 'Number', name : 'num', width : 80, sortable : true, align: 'right'}
				],
			
			searchitems : [
				{display: 'Test Code', name : 'tst_code'},
				{display: 'Test Name', name : 'test_name', isdefault: true}
				],
			sortname: "test_id",
			sortorder: "asc",
			usepager: true,
			title: 'TEST LIST	',
			useRp: true,
			rp: 10,
			showTableToggleBtn: true,
			width: 700,
			height: 255
			}
			);   
	
return false;
});
});
 
</script>
</head>
<br /><br />
 
<body align="center" bgcolor="#ffffff">
<form method='post' action='<? $_SERVER['PHP_SELF'] ?>' onsubmit='return validate_form();'>
 
<div id="statediv">Test Name:&nbsp;&nbsp;&nbsp;<select id="test_n" name="test_name"  >
	<option value="test" >All</option>
    <option value="test1" >All2</option>
    
        </select>
		<input type="submit" value="submit"></div>
<?
//echo $_REQUEST['sortname'];
echo "<table id='flex1' style='display:none' ></table>"
?>
 
</form>
<br /><br />
 
</body>
</html>

Open in new window

0
whspider
Asked:
whspider
  • 2
1 Solution
 
prokvkCommented:
How about posting your validate_form() function ?
0
 
whspiderAuthor Commented:
am not using validation....

i just want the grid the have values based on the selected options
0
 
whspiderAuthor Commented:
thanks i found it myself.i included the following and it worked

var fname=$('#test_n option:selected').val();
var fname1=
jQuery('#flex1').flexOptions({newp:1, params:[{name:'type', value: fname},{name:'sal',value:fname1}]});
jQuery("#flex1").flexReload();
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now