IF Else statement error

Discussion in 'JavaScript' started by linksprocket, Feb 4, 2010.

  1. #1
    This code works

    <script language=vbscript>
    Function updatedrop()
    if data.role.value = "1" then
    appl.innerHTML="<select name=appls multiple><option>Microsoft Project</option><option>Microsoft Visio</option><option>Microsoft Word</option></select>"
    else
    appl.innerHTML="<select name=appls multiple><option>Microsoft Project</option><option>Microsoft Visio</option><option>Microsoft Word</option><option>Microsoft Excel</option></select>"
    end if
    end function
    </script>

    Need to add another innerHTML

    <script language=vbscript>
    Function updatedrop()
    if data.role.value = "1" then
    appl.innerHTML="<select name=appls multiple><option>Microsoft Project</option><option>Microsoft Visio</option><option>Microsoft Word</option></select>"
    else
    appl.innerHTML="<select name=appls multiple><option>Microsoft Project</option><option>Microsoft Visio</option><option>Microsoft Word</option><option>Microsoft Excel</option></select>"
    else
    appl.innerHTML="<select name=appls multiple><option>Microsoft Project</option><option>Microsoft Visio</option><option>Microsoft Word</option><option>Microsoft Excel</option></select>"
    end if
    end function
    </script>

    This throws a error with the if statement.

    Any ideas?
     
    linksprocket, Feb 4, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What browser from which weird dimension supports vbscript? Seriously - use JS or something.

    You have two 'else' statements - use one `If', one `ElseIf', and make the last `Else'
     
    krsix, Feb 4, 2010 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    You are setting exactly the same value to appl.innerHTML, with the third else statement? For one there cant be a third else statement, you need to use else if... But that would not be necessary.... because they would both do the same thing. So one else statement is all that is required.
     
    camjohnson95, Feb 5, 2010 IP