Total members 11895 |It is currently Tue Dec 03, 2024 5:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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.




Author:
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Javascript select menu validation issue
 Javascript Validation On Multiple Select Lists     -  
 Validation of php drop down menu of months,days and years     -  
 validation using JavaScript     -  
 Email validation in Javascript     -  
 Issue in ajax     -  
 select query example in php     -  
 Word & ASP.Net ISSUE     -  
 Select odd rows from table     -  
 Change the content of select tag using JQuery     -  
 how to issue the command of Ctrl-C in Java     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com