I am trying to dynamically change the shading on a table column, based on the value of a drop-down, to reflect which column is being sorted by the drop-down. I am able to change the shading with no problem, but am having problems with identifying the index number of the drop-down box.
I am attempting to use the following script to get the index number for the drop down and use that to change the shading.
<script>
function display() {
var index = document.getElementById("DROPDOWN_ID").selectedIndex;
document.write(index);
}
</script>
My questions are:
1. I know that there are different forms of "document.getElementby" based on what element you are looking for. Is this the correct form?
and
2. Based on the Chrome developer tools element inspector, it appears that the dropdown ID is "asorting" (see attached picture). Is this how to find the ID for the control so I can query the index?
I suspect that the answer is somewhere between #1 and #2, which ends up with me spinning my wheels. I am just learning to dive deeper into the code and really appreciate any guidance.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
eetimm
I am trying to dynamically change the shading on a table column, based on the value of a drop-down, to reflect which column is being sorted by the drop-down. I am able to change the shading with no problem, but am having problems with identifying the index number of the drop-down box.
I am attempting to use the following script to get the index number for the drop down and use that to change the shading.
<script>
function display() {
var index = document.getElementById("DROPDOWN_ID").selectedIndex;
document.write(index);
}
</script>
My questions are:
1. I know that there are different forms of "document.getElementby" based on what element you are looking for. Is this the correct form?
and
2. Based on the Chrome developer tools element inspector, it appears that the dropdown ID is "asorting" (see attached picture). Is this how to find the ID for the control so I can query the index?
I suspect that the answer is somewhere between #1 and #2, which ends up with me spinning my wheels. I am just learning to dive deeper into the code and really appreciate any guidance.
Thanks,
ET
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.