473,657 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

two fucntions trigger by onClick

Hey,

what I try to do is when a user clicked an image button on my
site, I use onClick to trigger a dialog box and at the same time I use
button.attach(" onClick", savecookie) to mark this visitor so that next
time he comes back I can recognize him.If he did not click this image
button on my site, next time I would treat him as a new visitor.

My dialog box works as I expected but it seems that savecookie
function does not do its job since I could not find any cookies
stored. I am using IE7. Anyone has any idea about this? It means that
I cannot trigger two functions from one onclick?
<html>
<head>
<TITLE>THIS IS TEST </TITLE>

<SCRIPT LANGUAGE="JAVAS CRIPT" TYPE="TEXT/JAVASCRIPT">

function buttonLoad()
{
var button = document.getEle mentById("my_bu tton");

if(isTargetPers on())
{

button.attachEv ent("onClick", markVisit);

}
else {
button.style.vi sibility="hidde n";
}

}

function isTargetPerson( )
{
if (document.docum entElement && (typeof
document.docume ntElement.style .maxHeight!="un defined" )&&
window.XMLHttpR equest && isNewbie() )
return true;
else
return false;
}

function isNewbie()
{
var allcookies = document.cookie ;

var pos = allcookies.inde xOf("newbie=");
//alert(pos);

if (pos == -1)
return true;

else {
var start = pos + 7;
var end = allcookies.inde xOf(";", start);
if(end == -1) end = allcookies.leng th;
var value = allcookies.subs tring(start, end);
if (value == "false")
return false;
}

}

function markVisit()
{
var today = new Date();
today.setFullYe ar(today.getFul lYear() + 1);

document.cookie = "newbie=false;e xpires=" + today.toGMTStri ng();
}
</SCRIPT>
</head>

<BODY>

<div id="search">
<INPUT TYPE="image" id="my_button" src="sp_ie7.gif "
VALUE="somevalu e" onClick=somefun ction");'>
</div>

<script language="javas cript"window.on Load=buttonLoad (); </script>

</BODY>

</html>

Feb 16 '07 #1
1 1738
On Feb 17, 1:18 am, zhengya...@gmai l.com wrote:
Hey,

what I try to do is when a user clicked an image button on my
site, I use onClick to trigger a dialog box and at the same time I use
button.attach(" onClick", savecookie) to mark this visitor so that next
time he comes back I can recognize him.If he did not click this image
button on my site, next time I would treat him as a new visitor.

My dialog box works as I expected but it seems that savecookie
function does not do its job since I could not find any cookies
stored. I am using IE7. Anyone has any idea about this? It means that
I cannot trigger two functions from one onclick?
Yes you can. The easiest way though is to call one function from the
other, then you only need to attach one handler.
>
<html>
<head>
<TITLE>THIS IS TEST </TITLE>

<SCRIPT LANGUAGE="JAVAS CRIPT" TYPE="TEXT/JAVASCRIPT">
The language attribute is deprecated, keep type.

[...]
<BODY>

<div id="search">
<INPUT TYPE="image" id="my_button" src="sp_ie7.gif "
VALUE="somevalu e" onClick=somefun ction");'>
----------------------------^-----------^

It's always a good idea to start with valid markup. I think you
wanted something like:

... onclick="somefu nction();">

</div>

<script language="javas cript"window.on Load=buttonLoad (); </script>
Javascript is case-sensitive, try:

window.onload = ...
There may be other errors.
--
Rob

Feb 17 '07 #2

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

Similar topics

2
2178
by: DS | last post by:
Hi, I can trigger these events successfully if table only has one row: Sub InputField_OnChange() ...... End Sub But, these events cannot be fired if table has more than one row, why? Pls advise solutions. Thanks.
6
5184
by: amith | last post by:
hi, i have some 10 radio buttons meant to take the rating from the user. ex: 1 2 3 4 5 6 7 8 9 10 looks O O O O O O O O O O 1 2 3 4 5 6 7 8 9 10 features O O O O O O O O O O
17
61427
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an onClick JS event defined, I'd want that onClick event to execute too, exactly the same as if the user...
2
11357
by: kj | last post by:
How does one trigger an event programmatically? I'm interested in how to do this in both the "Level 0" event model as well as in the DOM Level 2 event model. Thanks! kj -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded.
2
3895
by: Sally B. | last post by:
Hi, I have a main page that opens a pop up window when the user clicks a link. The pop up window is a menu and when the user clicks the item, it populates a form input element on the 'parent' window. My question is: this new populated form element is the value that I use to change a style. onchange does not watch this form element because of getelementbyid, so
1
1878
by: ramalingam | last post by:
Hi I am very new to PHP. Please help. I have a HTML code in a php file which takes in USERID and password. I have <input name="Submit" type="button" value="Submit" onClick="funCheck()"/>, funCheck is a function which makes sure that something is entered in the userid/password fields. This function is present in the same PHP file. employee_data.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
13
36086
by: Ralph | last post by:
Hi Is it possible to trigger the certain event from JS function? I have an image with on click event handler assigned. Now if like to trigger this event for this image from some other function. --
4
2429
by: gregincolumbus | last post by:
I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes. Ideally, a change of select1 1. trigger the population of select2 (and set it initially to 0) 2. make the text fields disappear 3. trigger the financial calculation to reflect the select1 choice. Any help would be greatly appeciated !
1
1639
by: Mahesh J K | last post by:
Hi, Pls help me in solving this problem. How to trigger radio button element's eventhandler from the mail body of the mail I am trying like this... strHTMLBody = "<html><head><script language='javascript'>function fdBckMail(){alert('HI')}</script></head><body><CENTER><SPAN style='FONT-SIZE: 10.5pt; COLOR: #0000ff; FONT-FAMILY: Bookman Old Style'>***********THIS IS AN AUTOGENERATED MAIL***********</span><BR><BR></CENTER><SPAN...
0
8385
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
8821
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...
1
8502
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4150
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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

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.