Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

IMO Needs some Javascript Behaviour

Javascript coding ..

Moderators: macek, egami, gesf

IMO Needs some Javascript Behaviour

Postby TheProdigyGuy » Thu Feb 23, 2012 11:55 am

Hi Guys,i need small help to complete my small project)

I have simple js+html selection (aka combo box).
It works like charm but i need a bit *trick* it for my needs.
Problem in that it has default selected value when i call it *first time* (in eg: <option>1</option>)
When i select that <option>1</option> (without switching to other values) (in this case value = 1) i want it to alert(value) but can't figure it out because if it is selected *previously->currently* it will not alert(that.value)
I played with a lot of javascript behaviours in eg: (Onclick,ONDBLICK,ONfocus,Onselect,OnmouseOver,Onblur) etc.
Still can't figure it to work for my needs.
To be more clear again i need somehow (if possible of course) alert second time currently selected value without switching to other values.

TIA.


Code: Select all
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  alert(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<form name="form" id="form">
  <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
    <option>1</option>
    <option>2</option>
    <option>3</option>
  </select>
</form>

</body>
</html>

TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron