[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/26/2009 at 05:35AM PDT, ID: 24437776
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

php drop down list onChange not submitting the form

Asked by cyberwebservice in PHP Scripting Language, Web Languages/Standards

Hi,
This is a very simple code where I am populating a drop down list from mysql table PERIODS and upon selecting the value from the drop down, I want the starttime and endtime fields filled from the table PERIODS. Then the details are entered into another table on clicking the submit button.

I thought this is very simple and can be finished in 20 to 30 minutes. But I am struggling with this for more than 2 hours because the drop down change event does not do anything. I tried many variations and nothing works.

I don't want to use AJAX here, because, this code is to demonstrate to a beginner coder.  Also, if you find anything insecure in the code, please feel free to tell me.

Thanks.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
<? 
$host = "localhost";	//This is your mysql server host name
$db_user="lessons";//"dbuser";		//Substitute your Database user name here
$db_pwd="lessons";//"password";		//Substitute your Database user password here
$db_name="lessons";//"dbname";		// Your database name
$connection = mysql_connect($host, $db_user, $db_pwd)
or die (mysql_error()); //	'database_name' 
$db = mysql_select_db($db_name, $connection) or die (mysql_error());
?>
 
<?
$desc = mysql_real_escape_string($_POST['perioddesc']);
$query = "select * from periods order by Perioddesc";	//Querying the Periods table
$result = mysql_query($query) or die(mysql_error());	//Execute the Query
if($desc==""){
$option="<option>-- Select --</option>";
}else{
$option="<option>".$desc."</option>";
}
while($rs=mysql_fetch_array($result)){		// Fetch each record from the result set
$option.= "<option>".$rs['Perioddesc']."</option>";
}
?>
<?
if(isset($_POST['submit'])){
$desc = mysql_real_escape_string($_POST['perioddesc']);
$starttime = mysql_real_escape_string($_POST['starttime']);
$endtime = mysql_real_escape_string($_POST['endtime']);
$query = "insert into daylessons(lessondesc, starttime, endtime) values('$desc', '$starttime', '$endtime')";
$res = mysql_query($query) or die(mysql_error());
echo "Record inserted!";
}
?>
<!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>Day Lessons</title>
<script language="javascript">
function callsubmit(){
var dform = document.getElementById("daylessonfrm");
dform.setAttribute("action", "insertlesson.php?action=displaytime");
document.getElementById("daylessonfrm").submit();
//document.getElementById("daylessonfrm").action="insertlesson.php?action=displaytime";
//document.getElementById("daylessonfrm").submit();
}
</script>
</head>
<body>
<?
if($_REQUEST['action']=="displaytime"){
$desc = mysql_real_escape_string($_POST['perioddesc']);
$db_query = "select * from periods where perioddesc='".$desc."'";
$resultset = mysql_query($db_query);
$rowset = mysql_fetch_array($resultset);
$starttime = $rowset['starttime'];
$endtime = $rowset['endtime'];
}
 
?>
<form name="daylessonfrm" id="daylessonfrm" action="insertlesson.php" method="post" >
<span>Period : <select name="perioddesc" id="perioddesc" onChange="callsubmit();">
<? echo $option; ?>
</select></span>
<br /><br />Start Time: <input type="text" name="starttime" id="starttime" value="<?=$starttime?>"  />
<br /><br />End Time: <input type="text" name="endtime" id="endtime" value="<?=$endtime?>"  />
<input type="submit" name="submit" value="submit"  />
</form>
</body>
</html>
[+][-]05/26/09 06:03 AM, ID: 24472708

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/26/09 06:04 AM, ID: 24472718

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Web Languages/Standards
Sign Up Now!
Solution Provided By: cmaohio
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05/26/09 06:09 AM, ID: 24472782

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/09 08:23 AM, ID: 24474199

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/26/09 09:57 AM, ID: 24475115

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_EXPERT_20070906