473,396 Members | 1,726 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,396 software developers and data experts.

one click two functions

Hi ,

could anybody pls advice how can i combine two actions with one single click, herein below are my sample code :

Expand|Select|Wrap|Line Numbers
  1.  <SCRIPT LANGUAGE="JavaScript"><!-- 
  2.  
  3. //function no-1
  4.  
  5. function codename() {
  6.  
  7. if(document.formname.checkboxname.checked)
  8. {
  9. document.formname.textname.disabled=false;
  10. }
  11.  
  12. else
  13. {
  14. document.formname.textname.disabled=true;
  15. }
  16. }
  17.  
  18. //-->
  19.  
  20.  
  21. //function - 2
  22.  
  23. function checkBox(id_sub, obj_check)
  24. {
  25. var Submit = document.getElementById(id_sub); 
  26.  
  27. if (obj_check.checked == true)
  28. Submit.disabled = false;
  29. else
  30. Submit.disabled = true;
  31. }
  32.  
  33.  
  34. //function - 3
  35.  
  36. function basicFunctionBoth () {
  37. codename();
  38. checkBox('submit', this);
  39. }
  40.  
  41. </script>
  42.  
  43.  
  44. <form action="" method="" name="formname">
  45.  
  46. <input type="checkbox" onclick="basicFunctionBoth()" name="checkboxname" value="ON"> Do Both <br>
  47.  
  48.  
  49. <br>
  50. <input type="text" disabled size="10" name="textname">
  51. <br><br>
  52. <input type="submit" id="submit" value="Submit" disabled="disabled">
  53.  
  54. </form>
  55.  
my problem is :
1) the function is work when it is revoke separately
2) when i combine these two with a single function name "basicFunctionBoth" , it does not work.


kindly advice. thank you in advance
Aug 22 '06 #1
5 3318
PLA
44
In your function basicFunctionBoth(), 'this' is not the checkbox but the window object!
try
function basicFunctionBoth () {
codename();
checkBox('submit', document.formname.checkboxname);
}
It will work !
The better is to pass the chekbox as a parameter if you want to generalize this method!

Pascal
Aug 23 '06 #2
Hi,

Thank you for your very kind advice, it works well. Thank you again.

Warmest regards
Aug 24 '06 #3
An alternative to that is to do:

<input type="checkbox" onclick="combined(this);">

...
function combined(checkboxObject) {
codename();
checkpoks('submit', checkboxObject);
}
Aug 24 '06 #4
PLA
44
Yes, that's what I was thinking at when I wrote

pass the chekbox as a parameter
Aug 24 '06 #5
Thank you for the new suggestion.
Aug 26 '06 #6

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

Similar topics

7
by: Paul Cooper | last post by:
Dear All, I am working on a piece of Javascript code that needs to detect a mouse-click, shift-click and control-click. The code is not my own - it is a part of a much larger suite of routines....
29
by: lori3laz | last post by:
How do you disable the right click>view source option on web pages so people can't view your coding and copy it? What's the html I need to include in my website to utilize this feature? Thank...
5
by: MounilK | last post by:
this.btnMybtn.Click += new System.EventHandler(this.btnMyBtn_Click); private DataSet btnMyBtn_Click(object sender, System.EventArgs e) { DataSet dtsReportData = ShowReport(); return...
24
by: ej1002 | last post by:
Hi I have developed a Windows Application(C# Windows Form) which will get the IFrame Source of the page it is navigating using Webbrowser Control. Now I want do this in ASP.Net web application(C#...
6
by: Martijn Coppoolse | last post by:
Hello everyone, I've got two little apps which are able to create a window that displays something on the desktop, but are not clickable. Instead, when you click on the window, the item...
24
by: John Gabriel | last post by:
CreateDialogIndirect() fires my Radio button click function without the radio button having being clicked. I am using VC++ 2003.NET. I believe this is yet another Microsoft bug. Have checked dialog...
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
2
by: TheDude5B | last post by:
Hi, I have a procedure which calls different functions from within it and it takes a while to do different functions. I want to be able to change the display text during each stage, so when the...
6
by: user | last post by:
Hello, With ASP.NET2, how to program a button's click ? For example, I have two button and when i click the first one, i would like that the second one will be click too (by programming) ......
2
by: Peted | last post by:
Hi Im using c# express edition 2005 I have an MDI form, where i load multiple child forms from a dll i create, using reflection and late binding The child forms have multiple radio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.