473,382 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to call function in SELECT button using javascript

1
1.im using php programming.how to call a function using select button in form but no output has been shown........
2.script page
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function education_onchange()
  3. {
  4. alert("education onchange");
  5. }
  6. function personal_onchange()
  7. {
  8. alert("personal onchange");
  9. }
  10. </script>
3.body page..

Expand|Select|Wrap|Line Numbers
  1. <form name="form" id="form_job_seeker_home" action="" method="post">
  2. <table border="1">
  3. <tr>
  4. <td>
  5. <select >
  6. <option selected="selected">-select the option-</option>
  7. <option value="education" onchange="education_onchange();" id="education" >education</option>
  8. <option value="personal" onchange="personal_onchange();" id="personal">personal</option>
  9. </select>
  10. </td>
  11. </tr>
  12. </table>
  13. </form>
  14. </body>
Apr 6 '10 #1
2 6829
Dormilich
8,658 Expert Mod 8TB
you don’t call it on the <option> (because the option element doesn’t change) but on the select element.
Expand|Select|Wrap|Line Numbers
  1. <select id="test">
  2.     <option selected="selected">-select the option-</option>
  3.     <option value="education" id="education" >education</option>
  4.     <option value="personal" id="personal">personal</option>
  5. </select>
  6.  
  7. function alertChange()
  8. {
  9.     alert(this.value);
  10. }
  11. document.getElementById("test").addEventListener("change", alertChange, false);
works in all modern browsers
Apr 6 '10 #2
gits
5,390 Expert Mod 4TB
in this case you would need to handle the onclick events ... otherwise you would need to assign the onchange handler to the select node not to the option-nodes ...

kind regards

PS: nearly posted the same time :) ...
Apr 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
7
by: C.Joseph Drayton | last post by:
I have a problem that I am hoping someone can help me with. First let me describe the problem. I have an HTML form that in one field has an onBlur call to a JavaScript function. When you exit the...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
2
by: jmarendo | last post by:
Hello, After reading through the "Table Basics - DOM - Refer to table cells" example at mredkj.com , I modified the code for my own purposes. In the modified version, I create a hyperlink and...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
1
by: thirunavukarasukm | last post by:
I have a link wich opens a the second page with links wich call a javascript function. I have some problem with javascript. i am two aspx page.. in my first aspx page contain the second...
1
by: gabe | last post by:
How do you call a client side javascript callback method after an update panel has posted back to the server? I have two update panels (A + B) with a gridview in each panel. GridView B has a...
10
by: evicailieva | last post by:
A have a php scrip where I call a JavaScript function. I don't know why, but it doesn't work. At the beginning, when I was writing the script it was working but now it's not. I don't know wхat to do....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.