how to load values from form to jquery

Posted on 2009-04-04
Last Modified: 2012-06-27
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_select_db("lab")or die("CANNOT CONNECT To DATABASE".mysql_error());


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">


	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />


<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;	


			xmlhttp=new XMLHttpRequest();


		catch(e)	{		


				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");




				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");








		return xmlhttp;



$('form').submit(function() {

  var fname=$('#test_n').val();






			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;





<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>



		<input type="submit" value="submit"></div>


//echo $_REQUEST['sortname'];

echo "<table id='flex1' style='display:none' ></table>"



<br /><br />



Open in new window

Question by:whspider
  • 2

Expert Comment

Comment Utility
How about posting your validate_form() function ?

Author Comment

Comment Utility
am not using validation....

i just want the grid the have values based on the selected options

Accepted Solution

whspider earned 0 total points
Comment Utility
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}]});

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now