By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Show new list box when option selected from select box

P: 2
I have the following code :

[PHP]$form = "<head><title>:::Subjects:::</title></head>
<script src='ajax_files/prototype.js'></script>
<script src='ajax_files/getSecond.js'></script>
<body>
<form action='subjects.php' method='get' enctype='multipart/form-data'>
<table width='394' border='1' align='center' cellpadding='5' cellspacing='5'>
<tr>
<td>Programe Name:</td>";

$sql = "select programe_name from programmes";
$result = mysql_query($sql, $conn) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
$add .="<option value='$row[programe_name]'>$row[programe_name]</option>";
}

$form .= "<td>
<select name='prog_name' id='prog_name' onchange='getSecond(this.value)'>
<option value=''>--Select--</option>
$add
</select>
</td>
</tr>
<tr>
<td>Semester:</td>
<td><span id=\"comboHint\">";

$include = include('ajax_files/sublist.php'); // i don't know wat to do here? How to include this file?
// include "ajax_files/sublist.php";

$form .= "$include</span>
</td></tr></table></form></body></html>";[/PHP]

I am actually getting the programe names from the table inside the select box.
Now i want whenever a programe name is selected, for e,g bba, a new list box should appear with the total no of semesters for it.
i dont know how to put the sublist.php file between <span> </span> tags and run it there.
In the sublist.php file i have my list box.

And another question is, how can i maintain the format/design of my form?
because when i echo the file sublist.php it is showing me the list box on the top left corner instead of inside the cell, which i have mentioned.
Oct 24 '07 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

I have changed the thread title to give it a better description and make it easier for others with similar problems to find it.

What you want to do requires Ajax, but Ajax works by loading an initial page. Then a request is made to a server-side script (sublist.php) with the required parameters/arguments. This returns a response which you can use to modify/populate the page.

See an Ajax example.
Oct 25 '07 #2

P: 2
Welcome to TSDN!

What you want to do requires Ajax, but Ajax works by loading an initial page. Then a request is made to a server-side script (sublist.php) with the required parameters/arguments. This returns a response which you can use to modify/populate the page.

See an Ajax example.
Thankyou very much for the link.
By the way i am using ajax, and prototype.js library.
Oct 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.