Classic ASP read selected option value

Posted on 2014-01-20
Last Modified: 2014-01-26
The below code always returns the first option value, but I need it to return the selected value.
What am I missing.
This runs in a classic asp page.

set html = CreateObject("htmlfile")
                  html.write InstanceXMLFetchA_R.selectsinglenode("//scrunner[@SeqNo='1']/srcontent").textset termdetail = html.getElementById("termDetail")

 'html is some html content like this
<SELECT class=dtMM><OPTION value=1>1</OPTION><OPTION value=2>2</OPTION><OPTION value=3>3</OPTION><OPTION selected value=4>4</OPTION><OPTION value=5>5</OPTION><OPTION value=6>6</OPTION><OPTION value=7>7</OPTION><OPTION value=8>8</OPTION><OPTION value=9>9</OPTION><OPTION value=10>10</OPTION><OPTION value=11>11</OPTION><OPTION value=12>12</OPTION></SELECT> <SELECT class=dtDD><OPTION value=1>1</OPTION><OPTION value=2>2</OPTION><OPTION value=3>3</OPTION><OPTION value=4>4</OPTION><OPTION value=5>5</OPTION><OPTION value=6>6</OPTION><OPTION value=7>7</OPTION><OPTION value=8>8</OPTION><OPTION value=9>9</OPTION><OPTION value=10>10</OPTION><OPTION value=11>11</OPTION><OPTION value=12>12</OPTION><OPTION value=13>13</OPTION><OPTION value=14>14</OPTION><OPTION value=15>15</OPTION><OPTION value=16>16</OPTION><OPTION value=17>17</OPTION><OPTION value=18>18</OPTION><OPTION value=19>19</OPTION><OPTION value=20>20</OPTION><OPTION value=21>21</OPTION><OPTION value=22>22</OPTION><OPTION value=23>23</OPTION><OPTION selected value=24>24</OPTION><OPTION value=25>25</OPTION><OPTION value=26>26</OPTION><OPTION value=27>27</OPTION><OPTION value=28>28</OPTION><OPTION value=29>29</OPTION><OPTION value=30>30</OPTION><OPTION value=31>31</OPTION></SELECT> <SELECT class=dtYYYY><OPTION selected value=2013>2013</OPTION><OPTION value=2014>2014</OPTION></SELECT></TD>

Question by:KeithMcElroy
  • 2
LVL 33

Expert Comment

by:Big Monty
ID: 39794634
what is this line supposed to do?


which item do you want to be selected?

Author Comment

ID: 39794934
I just need to retreive the selected option into a local variable, so end game will be something like.

dim selval
selval = termdetail.getElementsByTagName("tr")(0).getElementsByTagName("td")(1).getElementsByTagName("select")(0).getElementsByTagName("option")(selectedIndex).value
LVL 33

Accepted Solution

Big Monty earned 500 total points
ID: 39794950
do you have the option to give the select box an ID or NAME attribute? if so, you would do:

var selVal = document.getElementById('selectBoxID').options[ document.getElementById('selectBoxID').selectedIndex ].value;

when you say "local variable", I assume you meant after the user selected an item. You would need to use javascript to retrieve it, which I provided an example for

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Update Stored Procedure question 8 54
Autosum input type=text when checkbox is true 28 94
Classic ASP - x-editable save to SQL 3 93
Adding Datediff to staistics page 2 56
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question