hello..
i have one dropdown box in while loop. when i am select one option for one row without submit it can only change. how to do?

actually i am retriving data from database. here status dropown is here. then i selected status on dropdown for particular content. so it con change the status of particular content with out submit.

can we see the code please?.. explain more please..

u can send the select box parameters through url like this

<select name="order" id="order" onChange="changeval(this.value)">
                  <?
				    $sel_merch="select * from table";
			  $merch_res=mysql_query($sel_merch);
			  $i=0;
			  while($fetch=mysql_fetch_assoc($merch_res)){
			 
				  ?><option value="<? echo $i;?>_<? echo $fetch['m_id_pk'];?>"><? echo $i;?></option><? $i++; }?>
				  </select>

and javascript function is

function changeval(id){
window.location.href="manage_merchants.php?order="+id;
}

you mean want to change your dropdown without without refreshing the page? then use AJAX

oh, i got you.. hope this helps

<html>
        <head>
		 <?php
 
 $db_connection = mysql_connect("localhost","youser","busword");
 
 $db="help";
 
 mysql_select_db($db);

 ?>
 <script src="help.js" type="text/javascript"></script>
 		</head>
   <body>
      <select name="order" id="order">
 
      <?php
  
      $sel_merch="select * from testtbale";
  
      $merch_res=mysql_query($sel_merch);

     while( $results=mysql_fetch_array($merch_res)){
 
	echo  "<option value=\"".$results['m_id_pk']."\">";
	echo  $results['m_id_pk']."</option>";
	}
	?>

javascript file:

window.onload=start;
 
 function start(){
 document.getElementById("order").onchange=function(){
	 var theVal = this.value;
	 window.location="manage_merchants.php?order="+theVal;
 }
 }

did it help?

Member Avatar for diafol

The js window.location solution will have the effect of redirecting/submitting - well loading a full page - whatever you wanna call it. Because this is a straightforward shot to a url.

You're better off with an ajax solution. Have a look at jQuery or prototype implementations of dropdown content changers. This is a very basic use of ajax - you shouldn't have much trouble using it.

At most you'll need the following:

1) the main page with the dropdown
2) ref to a js library in the head area
3) either an external js file for your ajax functions or inline script in the head area.
4) an external php file to handle ajax calls (receive data, process and return data).

Caveat: Ajax is well-known for poor accessibility issues. Sending data through a dropdown as opposed to using a proper submit button may cause problems. I'm no accessibility guru, so couldn't really say for certain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.