Hi,

[B]while($row = mysql_fetch_array($result))
$rows[] = $row['crseid'];
print "<td>";
print "<select name='ccrseid'>";
foreach($rows as $row)
{ 
     echo "<option value='$row' selected>$row</option>";

}
print "</select>";
print "</td>";
[/B]

Always, i am getting the last values. I can't retrieve the remaining values. Without $_POST[] ARRAY,how i can print the select option values without by clicking "submit" button and once by changing the select option values, and the values in the text box should gets changed. Thanks in advance

"<select name='ccrseid' MULIPLE SIZE=10>";

If you want to do things without submitting, then you must use javascript to do so.

hi,
"<select name='ccrseid' MULIPLE SIZE=10>";

why should use MULIPLE SIZE=10..? what is the meaning?

Below is JavaScript for submitting form on change of drop-down.

print "<select name='ccrseid' onchange='document.getElementById(\'formId\').submit();'>";

Where formId is the id of form tag.

I can't retrieve the remaining values.

After form submission You can only get one value that user have selected.
Why do you want all values in drop down?

why should use MULIPLE SIZE=10..? what is the meaning?

I guess If you want allow user to select multiple items. It will show 10 items in one screen.

Hi,
I dont need all the values from select option. When i am selecting some values from drop down box...i need only that value which am i choosing.


print "<select name='ccrseid' onchange='document.getElementById(\'formId\').submit();'>";

Above one is that javascript code. What is the purpose to add the above one?

That line was for submitting form without button click.
BTW here is one demo code which may help you.

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script language="javascript">
function showMe(str)
{
	document.getElementById('myDiv').innerHTML = ' You have selected : '+str;
}
</script>
<select name="ccrseid" onchange="showMe(this.value);">
<option value="">Select</option>
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</option>
<option value="Four">Four</option>
</select>
<div id="myDiv"></div>
</body>
</html>

Hi,
I got it what i expected. But, how can i print "str" values inside PHP tags. "str" value is inside in javascript...how can i print this values inside PHP tags anywhere. THANKS

Hi,

I have modified the code of vibhadevit for you. hope this helps.

<?php
$link = mysql_connect('localhost','palak','palak');
$seldb = mysql_select_db('apalgujarati',$link);

$getuserqry = mysql_query("select id,name from apal_user");
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script language="javascript">
function showMe(str)
{
	document.getElementById('myDiv').innerHTML = ' You have selected : '+str;
}
</script>
<select name="ccrseid" onchange="showMe(this.value);">
<option value="">Select</option>
<?php
while($getuserrow = mysql_fetch_array($getuserqry))
{
?>
<option value="<?php echo $getuserrow['name']; ?>"><?php echo $getuserrow['name']; ?></option>
<?php } ?>
</select>
<div id="myDiv"></div>
</body>
</html>

This will fetch all of your data from the db and also display the selected name.

Hope this will work for you. :)

str variable is in JavaScript. It is client side language.
While PHP is server side language.
Can you post your reason for passing str value to php tag with example.

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.