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

Validation of drop down menu and radio from dynamic display form

P: 22
Hi anybody. I am newbie here and would like to know that how can I validate both drop down menu and radio button from a dynamic display form.Something went wrong with my script.The radio button is dynamic,however drop down menu is static.

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/JavaScript">
  2. function formSubmit(obj)
  3. {
  4.     var returnStatus = 1;
  6.     if (obj.rNumber.selectedIndex == 0 || 
  7.         !(movieList.time[<?php echo $rows['name'];?>].checked)) { 
  8.         alert("Please select!");
  9.         returnStatus = 0;
  10.     };
  12.   }
  13. </script>
if (isset($_SESSION['gmemberid'])) {

$tbl_name = "movie";
$result = mysql_query(sprintf('SELECT name,category,screeningTime FROM %s
LIMIT 7', $tbl_name)) or die('Cannot execute query.');

//$numrow = mysql_num_rows($result);

while ($rows = mysql_fetch_assoc($result)) {
echo '<table width="100%" border="0"><tr><td height="68">
<table width="100%" height="47" border="0">

echo '<strong>' . $rows['name'] . ' (' . $rows['category'] . ')
foreach (explode(',', $rows['screeningTime']) as $time) { ?>
<input type="radio" name="time[<?php echo $rows['name']; ?>]"
value="<?php echo $time; ?>">
<?php echo $time; ?>&nbsp;&nbsp;&nbsp;
<?php } ?>



<input name="request" type="submit" id="request" value="Submit Request" onClick="formSubmit(document.movieList)">
Sep 23 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 5,058
Hi vinceboy. Welcome to The Scripts!

I don't see any code for a dropdown menu. The code for the radio buttons looks ok tho.

One minor concern tho.
You use explode() on a the data returned by your database. As a rule, no field in you database should contain more than one piece of data. This is the first (1NF) of three rules you should always keep in mind when designing a database. You can read more about them in this article: Normalisation and Table structures .
Sep 23 '07 #2

P: 22
The drop down menu is static display
<select name="rNumber" id="select4">
<option selected>Select</option>

At this moment, I need to know whether any what went wrong at that validation while PHP mix up with Javascript.Thanks for your generious help
Sep 23 '07 #3

Post your reply

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