473,623 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is that possible to call onclick from JS ?

abs
Hi all.

Is that possible to call the onclick, onchange or other event from JS ? I
mean how to make the browser think that user clicked the element (onclick
event) ? Eg. I have <element onclick='myFunc tion()'> and I don't want to
call the myFunction() by writing its name in the code but I want to call the
onclick event without clicking :) I don't know how to explain it better, I
hope you know what I mean.

Best regards,
ABS
Jul 23 '05 #1
2 20500
"abs" <ab**********@a lpha.net.pl> wrote in message
news:d3******** **@news.onet.pl ...
Hi all.

Is that possible to call the onclick, onchange or other event from JS ? I
mean how to make the browser think that user clicked the element (onclick
event) ? Eg. I have <element onclick='myFunc tion()'> and I don't want to
call the myFunction() by writing its name in the code but I want to call the onclick event without clicking :) I don't know how to explain it better, I
hope you know what I mean.

Best regards,
ABS

So you don't want:

<script type="text/javascript">
myFunction();
</script>

And you don't want an "onclick" to invoke it.

An function is invoked -- how else would you invoke it?!
Jul 23 '05 #2
abs wrote:
Hi all.

Is that possible to call the onclick, onchange or other event from JS ? I
mean how to make the browser think that user clicked the element (onclick
event) ? Eg. I have <element onclick='myFunc tion()'> and I don't want to
call the myFunction() by writing its name in the code but I want to call the
onclick event without clicking :) I don't know how to explain it better, I
hope you know what I mean.

Best regards,
ABS

If I understand you, you want to simulate the click by triggering an
"onclick" event based on something else. You want the user to still be
able to click on the button manually, but want the option of faking the
click after they do 2 or 3 other things.

If the above is correct, you want the click() method. All you need to do
is use the DOM address of the element in question and call:

element.click() ;

Keep in mind that this doesn't work for all form elements, but does work
for the ones you *should* be thinking about for this purpose: buttons,
checkboxes, radio buttons, resets, submits and selects.

This method is part of the set of methods that you can use to simulate
most user interactions and includes: blur(), focus(), select() as well
as click().

Once you go down this road, be careful of infinite loops in your code
where you trigger an event that triggers an event, etc.

J Wynia
Myriad Intellect, Inc.
www.myriadintellect.com
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6795
by: j_liu21 | last post by:
I'm trying to trigger a javascript call when someone clicks on an image. <a href="javascript:void(0)" onClick="alert('hi');"><IMG src="foo.gif" usemap="#someImageMap" border="0"></a> This works in I.E., but will only work in Mozilla (using 1.0.5) if there is text and the user must click on the text and not the image to trigger the alert:
21
8137
by: Ben | last post by:
Hello I have frames set up in an asp.net application and need one frame to refresh another. Seeing as events need to be registered at the time the page is sent from the server, I was wondering if I could place a hidden button in a frame that would have the attribute to refresh the other. I would need code to "invoke" the onclick event (ie i need code to click the button). is this possible? thanks.
8
2381
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web page will be viewed using Microsoft's IE browser (version 6.x ....). Webapge is self-contained. i.e., it does not refer to any links outside the webpage, however, it uses bookmarks inside the same page. I have a long table to display, table has...
0
2375
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr = 1) br.select_form(name="foo") br.select_form(name=foo) br.select_form(name="foo")
51
4367
by: Paul Gorodyansky | last post by:
Hi, Ran into the following problem while trying to have a code to attach a Virtual Keyboard to any user's form: User clicks a button and my JavaScript changes outerHTML of say <textarea - adding things like ONCLICK='saveCaret(this)' etc. and it also tries to save any text that user could've entered before the button press.
10
6071
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 button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
1
1625
by: stephen.cunliffe | last post by:
Situation: I have a few event handlers (not onclick) on a text box. The handlers take in an event parameter to work some magic. All the above works fine, but I have a desire/need, to "invoke" the same handlers, but from another element (e.g. a separate button) I know that someObject.click(); will actually work, but in my case, I do not want to invoke the onclick handler.
1
8152
by: Matt Brown - identify | last post by:
Hello, My goal is to make an input check box that saves an input text to a cookie when checked and destroys the cookie when unchecked. I figured i could use the onclick method of the input box to execute the PHP function setcookie, but how do I get the value from the input text? Testing with the window.alert function, inputtextName.value doesn't work in the PHP:
3
5535
by: chaitanya83 | last post by:
Is it possible to call both events onclick,ondblclick in div tag?
0
8224
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8667
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8610
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8469
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1471
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.