Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Classic ASP read selected option value

Posted on 2014-01-20
3
Medium Priority
?
903 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

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 33

Accepted Solution

by:
Big Monty earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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