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

Attaching javascript event to a built in advance html file...

Hi,

I need to attach a javascript function I wrote to the onChange event of
a <select> tag. However, I'm using a 3rd party tool that creates the
html files - it only lets me add bits of html to it, I can't touch the
elements it produces, so I can't just add an onChange="myfunction"
attribute to that <select> tag. I can't change the onload attribute of
the <body> tag.

How can I run code that attached my function to that event?

Thanks in advance,
R. Green

Apr 24 '06 #1
3 1345
zz****@gmail.com said the following on 4/24/2006 1:21 PM:
Hi,

I need to attach a javascript function I wrote to the onChange event of
a <select> tag. However, I'm using a 3rd party tool that creates the
html files - it only lets me add bits of html to it, I can't touch the
elements it produces, so I can't just add an onChange="myfunction"
attribute to that <select> tag. I can't change the onload attribute of
the <body> tag.

How can I run code that attached my function to that event?


Does your select have a name or id attribute?

If so, simply add an onchange event to it:

document.forms['formID'].elements['selectName'].onchange=functionToExecuteOnChange;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '06 #2
hi,

what if there are already functions that handle the event (either by
<select onchange="functionname">) or the equivalent
....elements["elementname"].onchange? how can i make sure that it's my
function that runs and not the others?

Randy Webb wrote:
zz****@gmail.com said the following on 4/24/2006 1:21 PM:
Hi,

I need to attach a javascript function I wrote to the onChange event of
a <select> tag. However, I'm using a 3rd party tool that creates the
html files - it only lets me add bits of html to it, I can't touch the
elements it produces, so I can't just add an onChange="myfunction"
attribute to that <select> tag. I can't change the onload attribute of
the <body> tag.

How can I run code that attached my function to that event?


Does your select have a name or id attribute?

If so, simply add an onchange event to it:

document.forms['formID'].elements['selectName'].onchange=functionToExecuteOnChange;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Apr 27 '06 #3
zz****@gmail.com said the following on 4/27/2006 3:10 AM:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
hi,

what if there are already functions that handle the event (either by
<select onchange="functionname">) or the equivalent
....elements["elementname"].onchange?
Did you test it to see? And if so, what happened?
how can i make sure that it's my function that runs and not the others?


You can start by testing it.

window.onload = resetSelectOnChange(){
document.forms['formID'].elements['selectName'].onchange=functionToExecuteOnChangeThatWillSuperse deAnyOtherThatWasAssignedBeforeNowAndWillExecuteUn lessYouRedefineAnotherOne;
}

Note the lack of () on the function name.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 27 '06 #4

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

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
5
by: knocte | last post by:
Hello. I am a web developer very worried about "bloat code" and "languages mixture". So, since some time, I always try to avoid completely the use of javascript in XHTML/HTML files. This leads...
2
by: JCE | last post by:
I need to programmatically invoke an asp:Button click event from a javascript function. The page containing the script and the button is the HTML page associated with a WebUserControl-derived...
4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
2
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.