Solved

Classic ASP read selected option value

Posted on 2014-01-20
3
867 Views
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>

termdetail.getElementsByTagName("tr")(0).getElementsByTagName("td")(1).getElementsByTagName("select")(0).getElementsByTagName("option")(selectedIndex).value
0
Comment
Question by:KeithMcElroy
  • 2
3 Comments
 
LVL 32

Expert Comment

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

termdetail.getElementsByTagName("tr")(0).getElementsByTagName("td")(1).getElementsByTagName("select")(0).getElementsByTagName("option")(selectedIndex).value

which item do you want to be selected?
0
 

Author Comment

by:KeithMcElroy
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
0
 
LVL 32

Accepted Solution

by:
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now