| | #1 |
| CustomBotSolutions.com War Room Member Join Date: 2007
Posts: 164
Thanks: 16
Thanked 21 Times in 19 Posts
|
How can achieve this. For example on this code: Code: <select name=""> <option value="test1">test1</option> <option value="test2">test2</option> <option value="test3">test3</option> </select> Please advise.. Thanks |
| Best Blog Commenting Software Youlikehits ROBOT - Earn 15k+ points daily for FREE! Contact me for your Custom Bot Needs - CLICK HERE! | |
| |
| | #2 |
| HyperActive Warrior War Room Member Join Date: 2009
Posts: 156
Thanks: 1
Thanked 11 Times in 10 Posts
|
Give the select object and id and in your javascript add something like: var dothis = function(){ return function(e){ var s = document.getElementById('yourId'); if(s.options[s.selectedIndex]=='test2'){ // YOUR CODE HERE } } } document.getElementById('yourId').onchange = dothis(); |
| | |
| |
| | #3 |
| CustomBotSolutions.com War Room Member Join Date: 2007
Posts: 164
Thanks: 16
Thanked 21 Times in 19 Posts
|
Hi kdavies thanks! How can I execute that function if any value on the list is selected?
|
| Best Blog Commenting Software Youlikehits ROBOT - Earn 15k+ points daily for FREE! Contact me for your Custom Bot Needs - CLICK HERE! | |
| |
| | #4 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
Here's another way to do it... Code: <!-- Javascript -->
<script type="text/javascript">
function test1() {
alert("You chose 1!");
}
function test2() {
alert("You chose 2!");
}
function test3() {
alert("You chose 3!");
}
</script>
<!-- HTML -->
<select name="">
<option value="test1" onclick="test1()">test1</option>
<option value="test2" onclick="test2()">test2</option>
<option value="test3" onclick="test3()">test3</option>
</select> |
| | |
| |
| | #5 |
| HyperActive Warrior War Room Member Join Date: 2009 Location: Australia
Posts: 225
Thanks: 40
Thanked 47 Times in 36 Posts
|
And if you want to use jQuery.. Code: <script type="text/javascript">
$(document).ready(function(){
$('#mySelect').change(function(){
var selectedOption = $(this).val();
alert("You selected " + selectedOption);
});
});
</script>
<select name="" id="mySelect">
<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
</select> |
| Software Marketing & Licensing System for WordPress Plugins, Themes & .NET Software >> 72 Hour Special << | |
| |
|
| Bookmarks |
| Tags |
| execute, function, javascript, selected |
| Thread Tools | Search this Thread |
| |