Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 9:55 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: Javascript select menu validation issue
PostPosted: Thu Nov 10, 2011 5:55 pm 

I am having trouble getting a value, or even multiple values, to validate a forced choice on an ensuing field from a select menu value chosen.

For instance, I have an HTML file with an included .js file that holds validation wrapped within one big function for the form.

Then, I have certain functions on various fields, or event handlers, that attempt to perform validations of various kinds.

On this one, I'm about halfway there.

I have the following HTML code/values.

Code:
[color=#FF8040]<select multiple name="multival" id="multival"   size="6" class="bodtxt9pt" onchange="checkListItems()" return false;>
                  <option value="bus1">Business 1</option>
                  <option value="bus2">Business 2</option>
                  <option value="bus3">Business 3</option>
                  <option value="Secbiz1">Secondary Biz 1</option>
                  <option value="Secbiz2">Secondary Biz 2</option>
                  <option value="Secbiz3">Secondary Biz 3</option>
                  <option value="Secbiz4">Secondary Biz 4</option>
                  <option value="tertbiz">Tertiary</option>
                  <!-- coming soon-->
                </select>[/color]


So if a secondary business (one or more or selected), the CheckListItems function calls an alert and unhides a new ID and set of table elements:

Code:
   [color=#FFBF40]<td colspan="4" id="financials" style="display:none"><span class="bodtxt9pt"> <em class="crtiicaltxt">Choose Financial Outlet</em><img src="../images/spacer.gif" width="100" height="1"> </span>
      <label>
        <select name="finopt" class="bodtxt9pt" id="citifiopt">
          <option value="--">Select One</option>
          <option value="ABCFi">ABC Financial</option>
          <option value="Plant">Plant Fin Group</option>
          <option value="Both">Both Financials</option>
        </select>
      </label></td> [/color]


The function looks like the following:

Code:
[color=#4080BF]function checkListBoxSize(){
var minNum=2; var maxNum=8;
var len = document.frmChangeCtrl.multival.length;
var chosen = "";
var chosiefr;
var j = 0;
for (j = 0; j < len; j++) {

if (document.frmChangeCtrl.multival[j].selected) {
chosen = chosen + document.frmChangeCtrl.multival[j].value + "\n"
chosiefr = chosen.match("Sec");
}
if (!(chosiefr == null)) {
   document.getElementById('financials').style.display='';
   alert('A secondary portfolio on multi branch is selected.');
         if (!(chosiefr == null) && (document.frmChangeCtrl.finopt.value == " ")) {
         alert('A secondary portfolio on multi branch isn\ selected so a financial branch must be chosen.');
         }
         return false;
   }
   else 
   {document.getElementById('financials').style.display='none';}
    }

return true;

}//end function[/color]



What I need the function to do is validate whether the field finopt, also a select menu, has had a value chosen IF the value of the previous select menu includes "Sec", as noted in the match method used.

I welcome any feedback or direction on this!

Thanks.


TOP
  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 Datepicker issue with Internet Explorer
 JavaScript fade out problem
 XML validation against DTD
 Radio Button list validation
 usage of menu tag
 javascript read file
 getting gst, pst total to diplay in my javascript form
 need help with javascript
 changing the background color for site main menu.
 select query example in php

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team