php - onChange event on two web pages -
i hava 2 web pages. 1 main.php , other combo.php. combo.php contains dropdown list , have included page in main.php.
what want when select option in dropdown, there should alert box indicating selected item.
main.php
<html> <body> <form> //some elements <?php include 'combo.php';?> </form> </body> </html>
combo.php
<html> <body> <form> //some elements <select name="combo"> <option value="1">america</option> <option value="2">england</option> <option value="3">india</option> <option value="4">japan</option> </select> //some elements </form> </body> </html>
i can't changes combo.php. onchange event , script should in main.php. have no idea how this, , don't no whether possible. regarding matter highly appreciated. thanx.
if can use jquery, have add piece of code in main.php
$(document).ready(function() { $("#idofyourselect").change(function(changeevent) { alert("your value : " + $(this).val()); }); });
assuming <select>
has @ least id idofyourselect
(or name, or css classname - somthing allow retrieve javascript code)
this add listener on change
event , run callback @ each time change value.
if can't use jquery, little more complicated, have play browser differences, , use addeventlister
or attachevent
add listener.
attachevent documentation (for old ie)
addeventlistener firefox, webkit, etc
i recommend use jquery, handle these differences you.
Comments
Post a Comment