[RESOLVED] Uncaught SyntaxError: Illegal return statement
Results 1 to 4 of 4

Thread: [RESOLVED] Uncaught SyntaxError: Illegal return statement

  1. #1
    Senior Member cluelessPHP's Avatar
    Join Date
    Apr 2015
    Location
    Scotland
    Posts
    429

    resolved [RESOLVED] Uncaught SyntaxError: Illegal return statement

    I'm looking at JS again, I keep getting the error

    Uncaught SyntaxError: Illegal return statement
    HTML Code:
    <script type="text/javascript">
    
    	var first = document.myform.firstSelect.options[document.myform.firstSelect.selectedIndex].innerText
        var second= document.myform.secondSelect.options[document.myform.secondSelect.selectedIndex].innerText
        var third= document.myform.thirdSelect.options[document.myform.thirdSelect.selectedIndex].innerText
        var fourth= document.myform.fourthSelect.options[document.myform.fourthSelect.selectedIndex].innerText
       
    	if(validate_required(first, "Please select an artist")==false)
    		{
    			return false;
    		}
    	
    	 else if(validate_required(second, "Please selcet a venu")==false)
    		{
    			return false;
    		}
    		
    	else if(validate_required(third, "Please select an artist")==false)
    		{
    			return false;
    		}
    	else if(validate_required(fourth, "Please select an artist")==false)
    		{
    			return false;
    		}
        return true;
    }
    
    
    
    function managefirstSelect(value)
    {
        var firstSelect = document.myform.firstSelect
        var secondSelect = document.myform.secondSelect
        var thirdSelect = document.myform.thirdSelect
        var fourthSelect = document.myform.fourthSelect
        var fifthSelect = document.myform.fourthSelect
        secondSelect.options.length = 0
        thirdSelect.options.length = 0
    
        if(value == "Madonna")
        {
            secondSelect.options[secondSelect.options.length] = new Option('Please select a venu :')
            secondSelect.options[secondSelect.options.length] = new Option('London')
            secondSelect.options[secondSelect.options.length] = new Option('Manchester')
            
        }
        if(value == "Rod Stewart")
        {
            secondSelect.options[secondSelect.options.length] = new Option('Please select a venu :')
            secondSelect.options[secondSelect.options.length] = new Option('London')
            secondSelect.options[secondSelect.options.length] = new Option('Manchester')
            secondSelect.options[secondSelect.options.length] = new Option('Glasgow')
            
        }
        if(value == "Beyonce")
        {
            secondSelect.options[secondSelect.options.length] = new Option('Please select a venu :')
            secondSelect.options[secondSelect.options.length] = new Option('Glasgow')
            secondSelect.options[secondSelect.options.length] = new Option('Manchester')
            secondSelect.options[secondSelect.options.length] = new Option('Birmingham')
            secondSelect.options[secondSelect.options.length] = new Option('London')
        }
        else if(value == "Guns and Roses")
        {
            secondSelect.options[secondSelect.options.length] = new Option('Please select a venu :')
            secondSelect.options[secondSelect.options.length] = new Option('London')
            
            
            
        }
        if(value == "Oasis")
        {
            secondSelect.options[secondSelect.options.length] = new Option('Please select a venu :')
            secondSelect.options[secondSelect.options.length] = new Option('London')
            secondSelect.options[secondSelect.options.length] = new Option('Glasgow')
            secondSelect.options[secondSelect.options.length] = new Option('Nottingham')
            
        }    
    }
    
    function managesecondSelect(value)
    {
        var secondSelect = document.myform.secondSelect
        var thirdSelect = document.myform.thirdSelect
        var fourthSelect = document.myform.fourthSelect
    	var fifthSelect = document.myform.fifthSelect
        var artist = document.myform.firstSelect.options[document.myform.firstSelect.selectedIndex].innerText
    
        if(artist == "Madonna" && value == "London")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date:')
            thirdSelect.options[thirdSelect.options.length] = new Option('17th of July')
            thirdSelect.options[thirdSelect.options.length] = new Option('18th of July')
            fourthSelect.options[fourthSelect.options.length] = new Option('30')
    		fourthSelect.options[fourthSelect.options.length] = new Option('45')
    		fourthSelect.options[fourthSelect.options.length] = new Option('70')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
        }
        else if(artist == "Madonna" && value == "Manchester")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date :')
            thirdSelect.options[thirdSelect.options.length] = new Option('21st of July')
            fourthSelect.options[fourthSelect.options.length] = new Option('25')
            fourthSelect.options[fourthSelect.options.length] = new Option('35')
    		fourthSelect.options[fourthSelect.options.length] = new Option('45')
    		fourthSelect.options[fourthSelect.options.length] = new Option('70')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
        }
       if(artist == "Rod Stewart" && value == "London")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date:')
            thirdSelect.options[thirdSelect.options.length] = new Option('13th of July')
            thirdSelect.options[thirdSelect.options.length] = new Option('15th of July')
    		fourthSelect.options[fourthSelect.options.length] = new Option('35')
            fourthSelect.options[fourthSelect.options.length] = new Option('50')
    		fourthSelect.options[fourthSelect.options.length] = new Option('60')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
            
        }
        else if(artist == "Rod Stewart" && value == "Manchester")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date :')
            thirdSelect.options[thirdSelect.options.length] = new Option('18th of July')
    		thirdSelect.options[thirdSelect.options.length] = new Option('20th of July')
    		fourthSelect.options[fourthSelect.options.length] = new Option('35')
            fourthSelect.options[fourthSelect.options.length] = new Option('50')
    		fourthSelect.options[fourthSelect.options.length] = new Option('60')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
            
            
        }
    	else if(artist == "Rod Stewart" && value == "Glasgow")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date :')
            thirdSelect.options[thirdSelect.options.length] = new Option('22nd of July')
    		thirdSelect.options[thirdSelect.options.length] = new Option('23rd of July')
    		fourthSelect.options[fourthSelect.options.length] = new Option('35')
            fourthSelect.options[fourthSelect.options.length] = new Option('50')
    		fourthSelect.options[fourthSelect.options.length] = new Option('60')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
            
            
        }
    	if(artist == "Guns and Roses" && value == "London")
        {
            thirdSelect.options[thirdSelect.options.length] = new Option('Please select a date:')
            thirdSelect.options[thirdSelect.options.length] = new Option('10th of July')
    		fourthSelect.options[fourthSelect.options.length] = new Option('88')
    		fifthSelect.options[fifthSelect.options.length] = new Option('1')
    		fifthSelect.options[fifthSelect.options.length] = new Option('2')
    		fifthSelect.options[fifthSelect.options.length] = new Option('3')
    		fifthSelect.options[fifthSelect.options.length] = new Option('4')
    		fifthSelect.options[fifthSelect.options.length] = new Option('5')
    		fifthSelect.options[fifthSelect.options.length] = new Option('6')
            
        }
    
    }
    </script>
    Once you had a good excuse, you opened the door to bad excuses ― Terry Pratchett, Thud
    Blog

    Six month project

  2. #2
    Senior Member cluelessPHP's Avatar
    Join Date
    Apr 2015
    Location
    Scotland
    Posts
    429
    HTML Code:
    <form name="myform" action="" method="post">
    
    <select name="firstSelect"  size="1" onchange="managefirstSelect(document.myform.firstSelect.options[document.myform.firstSelect.selectedIndex].innerText)">
    
      <option value="choose" selected = "selected">Select an artist:</option>
      <option value="madonna">Madonna</option>
      <option value="rod">Rod Stewart</option>
      <option value="Guns and Roses">Guns and Roses</option>
      <option value="Oasis">Oasis</option>
      <option value="Beyonce">Beyonce</option>
    
    </select>
    
    <select name="secondSelect"  size="1" onchange="managesecondSelect(document.myform.secondSelect.options[document.myform.secondSelect.selectedIndex].innerText)">
     <option value="">
             <br>
        Please select a venu:
    </select>
     
    <select name="thirdSelect" size="1">
      <option value="">
             <br>
        Please select a date:
      </option>
    </select>
    
    <select name="fourthSelect" size="1">
      <option value="">
             <br>
        Please select a ticket price:
      </option>
    </select>
    <select name="fifthSelect" size="1">
             <br>
        Please select How many tickets you wish to purchase:
      </option>
    </select>
    <br><br>
    
    <input type="submit" value = "Submit">
    
    </form>
    Once you had a good excuse, you opened the door to bad excuses ― Terry Pratchett, Thud
    Blog

    Six month project

  3. #3
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Contact Unit "Coping Mechanism"
    Posts
    22,503
    That first block of JS code there doesn't seem to be inside a function.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #4
    Senior Member cluelessPHP's Avatar
    Join Date
    Apr 2015
    Location
    Scotland
    Posts
    429
    Quote Originally Posted by Weedpacket View Post
    That first block of JS code there doesn't seem to be inside a function.
    Ah, thanks got it working
    Once you had a good excuse, you opened the door to bad excuses ― Terry Pratchett, Thud
    Blog

    Six month project

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •