Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Validate Menu lists when none selected



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
ammweb



Joined: 25 Mar 2007
Posts: 3

PostPosted: Mon Jun 23, 2008 9:50 pm    Post subject: Validate Menu lists when none selected Reply with quote

How would you validate a page that had several drop down menus. When the submit button is submitted, and NO selection has been made?

See code below:
<html>
<head>

</head>
<body>

<table width="100%" height="500px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="600px" valign="top" bgcolor="#F5F0DD"><table width="100%" height="452" border="1" bgcolor="#BFD5EA">
<form action="remcardqueue.asp" method="post">
<input name="subject" type="hidden" value="AMM | Remembrance Card Package Order" />
<input name="MAILCODE" type="hidden" value="XXXX" />
<tr>
<td height="66" colspan="3"><div align="center"><font color="#006633" size="5">Remembrance Card Package Selection</font></div></td>
</tr>
<tr>
<td width="22%" height="66"><div align="center"><img src="images/cards/1111.jpg" alt="Association Standard Remembrance Card Package" border="0"><br />
<span class="smallfont">Click to view details</span></div></td>
<td width="58%" class="surveysmall"><p><b><font color="#006633">Association Standard Remembrance Card Package</font><font color="#006600">(One of each of the cards shown here)<br />
</font></b><span class="surveyfont"> X1111</span> </p> </td>
<td width="20%" class="surveysmall"><div align="right">

<select name="X1111" id="X1111">
<option value="0">0</option>
<option value="1">1</option>
</select></div></td>
</tr>
<tr>
<td height="58"><div align="center"><a href="http://www.amm.org/cards/cdpkg/d011.asp" target="_NewWin"><img src="images/cards/D011.jpg" alt="Baby Remembrance" width="30" height="45" border="0"><br />
<span class="smallfont">Click to view details</span></a></div></td>
<td class="surveysmall"><p><b><font color="#006633">Baby Remembrance Folder</font></b><br />
<span class="surveyfont">D011</span> </td>
<td class="surveysmall"><div align="right">

<select name="D011" id="D011">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://www.amm.org/cards/cdpkg/dfp006.asp" target="_NewWin"><img src="images/cards/dfp006.jpg" alt="Family Prayer" width="32" height="45" border="0" /></a><br />
<a href="http://www.amm.org/cards/cdpkg/dfp006.asp" target="_NewWin"><span class="smallfont">Click to view details</span></a></div></td>
<td><p><span class="surveysmall"><b><font color="#006633">Family Prayer Folder
</font></b><br />
</span><span class="surveyfont">DFP006</span>
</td>
<td><div align="right">

<select name="DFP006" id="DFP006">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://www.amm.org/cards/cdpkg/dh215.asp" target="_NewWin"><img src="images/cards/DH215.jpg" alt="Healing Remembrance" width="30" height="41" border="0" /></a><br />
<a href="http://www.amm.org/cards/cdpkg/dh215.asp" target="_NewWin"><span class="smallfont">Click to view details</span></a></div></td>
<td><span class="surveysmall"><b><font color="#006633">Healing Folder</font></b><br />
</span><span class="surveyfont">DH215</span> </td>
<td><div align="right">

<select name="DH215" id="DH215">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://www.amm.org/cards/cdpkg/dh005.asp" target="_NewWin"><img src="images/cards/dh005.jpg" alt="Healing Remembrance" width="31" height="45" border="0" /></a><br />
<a href="http://www.amm.org/cards/cdpkg/dh005.asp" target="_NewWin"><span class="smallfont">Click to view details</span></a></div></td>
<td><span class="surveysmall"><b><font color="#006633">Healing Folder</font></b><br />
</span><span class="surveyfont">DH005</span> </td>
<td><div align="right">

<select name="DH005" id="DH005">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://www.amm.org/cards/cdpkg/dh106.asp" target="_NewWin"><img src="images/cards/dh106.jpg" alt="Healing Remembrance" width="30" height="42" border="0" /></a><br />
<a href="http://www.amm.org/cards/cdpkg/dh106.asp" target="_NewWin"><span class="smallfont">Click to view details</span></a></div></td>
<td><span class="surveysmall"><b><font color="#006633">Healing Folder</font></b><br />
</span><span class="surveyfont">DH106</span> </td>
<td><div align="right">

<select name="DH106" id="DH106">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr>
<td><div align="center"><a href="http://www.amm.org/cards/cdpkg/d3106.asp" target="_NewWin"><img src="images/cards/d3106.jpg" alt="Memorial Remembrance" width="32" height="45" border="0" /></a><br />
<a href="http://www.amm.org/cards/cdpkg/d3106.asp" target="_NewWin"><span class="smallfont">Click to view details</span></a></div></td>
<td><span class="surveysmall"><b><font color="#006633">Memorial Remembrance Folder</font></b><br />
</span><span class="surveyfont">D3106</span> </td>
<td><div align="right">

<select name="D3106" id="D3106">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></div></td>
</tr>
<tr bgcolor="f5f0dd">
<td colspan="4"><div align="center">
<p>&nbsp; </p>

<input type="submit" name="button" id="button" value="Create Your Card Package"/>
</div></td>
</tr>
</form>
</table>
</td>
</tr>
</table>

</body>
</html>
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 627
Location: Cebu City Philippines

PostPosted: Tue Jun 24, 2008 3:17 am    Post subject: Re: Validate Menu lists when none selected Reply with quote

I've made a response on to your other thread in CF.

...and the script is:
Code:

<script type="text/javascript">
window.onload=function()
{
var df=document.forms[0];
df.onsubmit=function()
   {
   var opts=document.getElementsByTagName('select');
   for(var i=0;i<opts.length;i++)
      {
      if(opts[i].value=='0')
         {
         alert('You need to choose at least one option');
         return false;
         }
      else
      return true;
      }
   return;
   }
}
</script>


Hope it was helpful.
Back to top
View user's profile Send private message Yahoo Messenger
ammweb



Joined: 25 Mar 2007
Posts: 3

PostPosted: Tue Jun 24, 2008 4:18 pm    Post subject: Re: Validate Menu lists when none selected Reply with quote

rangana wrote:
I've made a response on to your other thread in CF.

...and the script is:
Code:

<script type="text/javascript">
window.onload=function()
{
var df=document.forms[0];
df.onsubmit=function()
   {
   var opts=document.getElementsByTagName('select');
   for(var i=0;i<opts.length;i++)
      {
      if(opts[i].value=='0')
         {
         alert('You need to choose at least one option');
         return false;
         }
      else
      return true;
      }
   return;
   }
}
</script>


Hope it was helpful.
I tried adding your code to the code posted.

I got the error when nothing was selected, but I also got the error when I selected any of the list menu but the first menu list. If I selected the first menu list, the form submitted.

My question would be, how to validate all the menu lists? And if any one of the menu lists list a qty, than submit the form.

Thanks for your help so far.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap