a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

combining functions

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> combining functions
Page: [1]
 
sourkrouse

 

Posts: 28
Joined: 10/13/2007
Status: offline

 
combining functions - 10/14/2007 10:34:35   
I want to combine these 2 functions so that I can use 1 onSubmit handler. How can I do that?

First Function:
<script language="JavaScript">
function validate2(){ 


   var radios = document.getElementsByName("type");
   var sel_value = null;
   for(i=0; i<radios.length; i++) {
      if(radios.checked)
         sel_value = radios.value;
   }
   if(sel_value == "Other" && document.getElementById("other_type").value == "") {
      alert("Please specify an other type.");
      document.FrontPage_Form1.other_type.focus();

      return false;
   }
   return true;

}
</script>


Second Function:
<script language="JavaScript">
function validate1(){ 

ICOK=false;
for (ic=0;ic<6;ic++) {
if (FrontPage_Form1.type[ic].checked) return true;
}
if (!ICOK) {
alert('The Client Feedback Type is required. Please select One.');
return false;
}

}
</script>


When I try, only the first function runs, not both. What is happening is there are 6 radio buttons. One is an "other" selection that needs a text field entered. So first I want to validate that at least one radio is selected and then if other is selected, that the other text field is filled in. They work independantly. Thanks
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> General Web Development >> combining functions
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts