I have a dropdown list in the headerrow of a gridview.
When submiting data to the database, how can i check the value is selected or not from the dropdown list using javascript.

Thanks in advance.

7 Years
Discussion Span
Last Post by serkan sendur

You've posted on the wrong side of the forum, this query belongs to the javascript section. But since i've intercepted, this thread, then let me provide you with some help. Let's just perform a basic routine of capturing which part of the option has selected state, using a native alert.
All code is as follows:

<title>Check selected option using JAVASCRIPT</title>
<script type="text/javascript">
var check;
   check = function( ids ) {
   list = (( document.getElementById ) ? document.getElementById( ids ) : document.all[ ids ] );
   index = list.selectedIndex;
   return alert( list.options[ index ].value ); // Selected option will be alerted...
// -->
<form id="frm" action="#" onsubmit="return false;">
<div><select id="lst" name="lst" size="1" onchange="check( this.id );">
<option value="option 1">Option 1</option>
<option value="option 2">Option 2</option>
<option value="option 3">Option 3</option>

i think he posted to the correct forum but he needs to provide some code of his .aspx page. he cannot use pure javascript because he needs to use it within asp.net gridview control


So what's your problem, serkan? If you think you know everything, then speak less and prove it your self! Im referring it as a javascript example not as any other languages! You talked too much!


i didnt say anything offensive, i just said integrating javascript to asp.net controls is different story. so he doesnot need pure javascript examle. you must have some problem to take my words to be offended.


Let's take deep to the last portion of the main query, were it says

how can i check the value is selected or not from the dropdown list using javascript.

Did he ever asked anything, about using any code, concerned with .NET?

&#8212; You know that we have different sections' for different types of languages, and if your query points out something that belongs on this particular language then your post must be on that section.

And If i understand it correctly, what he really needs is a simple example from javascript so that he can properly associate everything with asp(x).

i've misinterpreted your post reading the last line of it, "i'm here to prove you wrong" and claiming it that it was part of the whole message -- w/o even noticing it, that it was your signature.
&#8212; my bad and sorry if i reacted that way...


i am not that level to say " i'm here to prove you wrong", i have been forbidden to mention my feelings about a code goddess in this website, who has that signiture. So i just cant stop pointing to her softly by having "i'm here to be proven wrong by you", and that you is not "you all" but exactly, specially, in particular that single individiual who i am not welcomed to say her name :)

Anyway take it easy, i wasnt offended that much, asp.net is one of my majors, and usually i dont post anything to this section unless i am sure of it. when you said something like " you talk to much", it was a bit heavy for me because of that reason.

Finally, i appreciate that you try to help him, but i claimed that integrating javascript to asp.net web controls is a different story, and probably he did post it to here intentionally. But i leave that question open until he verifies it.

Take it easy, all is fine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.