Click here to Skip to main content
15,909,324 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
creating any kind of drop-down list and alert show the selected value
The JavaScript and linking part to the file
Posted
Comments
dimpledevani 21-Nov-12 4:02am    
Can you Please explain in detail?? What you want and what have you tried??

XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <script>
<pre lang="cs">var myform = document.getElementById("someform")
for (var i = 0; i < myform.elements.length; i++) 
    if (myform.elements[i].type == "select-one" || myform.elements[i].type == "select-multiple") {
        myform.elements[i].className = "selectclass"
    }
}
    &lt;title&gt;Dropdown Alert&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;HTMLPage.htm&quot;&gt;

&lt;h1&gt;Choose one option at a time&lt;/h1&gt;
&lt;select id=&quot;sample&quot; onchange=&quot;alertselected(this)&quot;&gt;
    &lt;option value=&quot;val0&quot;&gt;GMAIL&lt;/option&gt;
    &lt;option value=&quot;val1&quot;&gt;TWITTER&lt;/option&gt;
    &lt;option value=&quot;val2&quot;&gt;FACEBOOK&lt;/option&gt;
    &lt;option value=&quot;val3&quot;&gt;INSTAGRAM&lt;/option&gt;
    &lt;option value=&quot;val4&quot;&gt;FLIXTER&lt;/option&gt;
&lt;/select&gt;
&lt;input type=&quot;button&quot; onclick=&quot;alertselected(document.getElementById())&quot; value=&quot;alert&quot; /&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
 
Share this answer
 
v2
Comments
MT_ 21-Nov-12 5:29am    
Posting a question and answer yourself and accpeting it.!!
deepak.m.shrma 21-Nov-12 5:46am    
LOL.... :-P down voted. :-P
but not the desired compact solution.
figured out though,, used this function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900