Javascript - finding a particular form from a mouse change event -


i have webpage 4 separate pulldown option forms , have javascript function gets invoked when of forms gets changed via mouse.

how establish specific forms changed event object , subsequently particular option change has been made?

all examples have seem assume have dedicated javascript function each individual form. want able build forms 'on fly' need pass forms changes through single javascript function.

in answer question - here's more info:

i use jquery (but i'm novice) - javascript event setup code line is:

 document.onchange=this.audioselect   

and audioselect function has single line @ moment - alert proves gets invoked each form change:

alert("audio select this: " + evtobj.type.tostring(). ).  

the forms defined similar 1 (with each subsequent form name being incremented:

"

    <div id="videoslot" style="position: absolute; left:250px; top:450.0px; background-     color:green;">            <img src="http://localhost:9000/homevu1/homevu1/skin/homevu.jpg"                                 width="210.0"                                 height="140.0"                                            alt="homevu1/skin/homevu.jpg"                                            title="homevu1/skin/homevu.jpg"/>                                                       <br />      <strong>select image 1 audio     <form name="audio_form_1" >       <select name="menu_1" >                 <br />     <option name = "audio_1" value = "1" >oh intro </option>      <option name = "audio_2" value = "2" >oh front </option>      <option name = "audio_3" value = "3" >oh plot </option>      <option name = "audio_4" value = "4" >oh hall </option> </select>   <br /> </form>  </div>" 

thanks in anticipation.

-mike

jquery suited task. attaching events can pain across different browsers. here link jsfiddle shows simple example of how achieve talking about: http://jsfiddle.net/uk2zh/1/

you need click run button @ upper left part of screen, make selections forms see alerts of selected where.

in jsfiddle attaching jquery event listener document - important if forms going created on fly. event listener set pay attention events happen within form elements.

$(document).on("change", "form", function(e){     var currentform = $(this);     var formname = currentform.attr('name');     var selectedoption = currentform.find('option:selected').val();     alert("form: " + formname + ", selected: " + selectedoption); }); 

the function attached receive element triggered event "this". can use more jquery (by wrapping "this" in jquery selector) easy access form name , selected option, etc.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -