Getting a select's value with javascript

前端 未结 3 873
青春惊慌失措
青春惊慌失措 2020-12-22 05:09

I have the following condensed form

提交评论

  • 2020-12-22 05:37

    Assign an ID to your select element:

    <select name="cars" id="cars">
    

    And you can get the value like this:

    document.getElementById('cars').value
    
    0 讨论(0)
  • 2020-12-22 05:38

    You are missing an =. Change this

    <form name "thecars">
    

    To this

    <form name="thecars">
    
    0 讨论(0)
  • 提交回复
    热议问题