Not getting complete variable when seperated by a space

Discussion in 'JavaScript' started by michaelh613, Nov 22, 2007.

  1. #1
    When I change my category I call a javascript function

    
    <select name="category" id = "category" onchange="showSubcategory()">
    
    Code (markup):
    In that function I grab the value for category

    
    var categorySelect = document.getElementById('category')
    var category = categorySelect.options[categorySelect.selectedIndex].value 
    
    Code (markup):
    When category is one word for expample computers it passes the data correctly, when it is two is only grabs the first one.

    strangely enough I do something similiar for subcategory and do not have teh same problem

    
    <select name="subcategory" id = "subcategory" onchange="showSubcategory2()">
    
    Code (markup):
    and

    
    var categorySelect = document.getElementById('category')
    var subcategorySelect = document.getElementById('subcategory')
    var category = categorySelect.options[categorySelect.selectedIndex].value   
    var subcategory = subcategorySelect.options[subcategorySelect.selectedIndex].value
    
    Code (markup):
    I am suspecting a "minor" syntax issue somewhere here
     
    michaelh613, Nov 22, 2007 IP
  2. michaelh613

    michaelh613 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What a difference a night of sleep makes. All of 3 hours. Problem was with PHP not escaping a quote
     
    michaelh613, Nov 23, 2007 IP