473,563 Members | 2,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript onchange problem

1 New Member
Hi everyone,

I am developing a web page for an embedded application. I created a text box for entering a value (only 1 byte long). The onchange event triggers correctly when I enter the value from a keyboard and press enter. However, it doesn't seem to fire when a javacript (a slider in this case) modifies the text box's value. I have tried:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("sd1").fireEvent("onchange"); and,
  2. document.getElementById("sd1").onchange();
  3.  
but none seems to work. The complete code is shown below. Please advice. Thank you in advance.
James

~inc:header.inc ~
[HTML]<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="StyleSheet " href="css/bluecurve.css" />

<script type="text/javascript" src="js/range.js"></script>
<script type="text/javascript" src="js/timer.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
</head>
<body>

<p>Vertical Slider</p>
<div class="slider" id="slider-1" tabIndex="1">
<input class="slider-input" id="slider-input-1"/>
</div>

<form method="get" action="demo.ht m">
<div>
<p>
Value:<input id="sd1" name="sdr1" style="color:wh ite" onchange="s.set Value(parseInt( this.value))"/>
</p>
</div>
</form>

<script type="text/javascript">
var s = new Slider(document .getElementById ("slider-1"), document.getEle mentById("slide r-input-1"), "vertical") ;

s.onchange = function () {
document.getEle mentById("sd1") .value = s.getValue();

document.getEle mentById("sd1") .fireEvent("onc hange"); --> THIS DOES NOT WORK
document.getEle mentById("sd1") .onchange(); --> THIS DOES NOT WORK
};
s.setValue(50);

window.onresize = function () {
s.recalculate() ;
};
</script>
<p>[/HTML]
~inc:footer.inc ~
Feb 29 '08 #1
6 8636
acoder
16,027 Recognized Expert Moderator MVP
See this link - section on manually firing events.
Mar 1 '08 #2
traineeirishprogrammer
24 New Member
Hi everyone,

I am developing a web page for an embedded application. I created a text box for entering a value (only 1 byte long). The onchange event triggers correctly when I enter the value from a keyboard and press enter. However, it doesn't seem to fire when a javacript (a slider in this case) modifies the text box's value. I have tried:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("sd1").fireEvent("onchange"); and,
  2. document.getElementById("sd1").onchange();
  3.  
but none seems to work. The complete code is shown below. Please advice. Thank you in advance.
James

~inc:header.inc ~
[HTML]<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="StyleSheet " href="css/bluecurve.css" />

<script type="text/javascript" src="js/range.js"></script>
<script type="text/javascript" src="js/timer.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
</head>
<body>

<p>Vertical Slider</p>
<div class="slider" id="slider-1" tabIndex="1">
<input class="slider-input" id="slider-input-1"/>
</div>

<form method="get" action="demo.ht m">
<div>
<p>
Value:<input id="sd1" name="sdr1" style="color:wh ite" onchange="s.set Value(parseInt( this.value))"/>
</p>
</div>
</form>

<script type="text/javascript">
var s = new Slider(document .getElementById ("slider-1"), document.getEle mentById("slide r-input-1"), "vertical") ;

s.onchange = function () {
document.getEle mentById("sd1") .value = s.getValue();

document.getEle mentById("sd1") .fireEvent("onc hange"); --> THIS DOES NOT WORK
document.getEle mentById("sd1") .onchange(); --> THIS DOES NOT WORK
};
s.setValue(50);

window.onresize = function () {
s.recalculate() ;
};
</script>
<p>[/HTML]
~inc:footer.inc ~
why exactly do you need to use the

document.getEle mentById("sd1") .onchange();

at all.

anyway if you are using this you need to assign it to a function . onchange is not a function itself
Mar 2 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
onchange is not a function itself
It might not be, but it can point to a function object - see An Introduction to Function Objects.
Mar 2 '08 #4
traineeirishprogrammer
24 New Member
Yeah I know that. Its an event.

Basically you can point to the function when an event occurs not an invocation.

i.e

document.getEle mentById("test" ).onclick = function()
{
alert(this.id);
};
Mar 4 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
document.getEle mentById("test" ).onclick = function()
{
alert(this.id);
};
Yes, now try this: document.getEle mentById("test" ).onclick();
Mar 4 '08 #6
traineeirishprogrammer
24 New Member
Yes I Know that I am declaring a reference to the function .
Mar 8 '08 #7

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

Similar topics

2
4122
by: Phil Powell | last post by:
I have a form with two single-choice dropdowns. Upon doing an onChange event on either one of them, I want to check to see if the other dropdown has also been selected. How would I do that, considering that this.parent causes an error "null or not an object"? Thanx Phil
2
570
by: Jeff | last post by:
Hi Everyone, I'm having a problem with onChange. The tag looks like: <input:text bean = "" name="X" label="Y" attributesText="onChange=\"clear()\""> </input:text> if i replace, onChange with onBLur, the call works. when i try using onchange without the attributesText it tells me onchange is not supported by the top level domain. if...
4
11934
by: rick | last post by:
The following basic script works fine in firefox by not in IE. Can anyone spot the problem? In IE I can only delete the first line but not the lines created by javascript. Also, look at the HTML code for the first line (click the Table HTML button:)) you will fine that the code displayed is not the same as was written. "onChange" was changed...
3
14833
by: countocram | last post by:
hi! Im having a problem retaining the inputs on my text fields. When i selected an option from a dropdown list with an onChange=location.. event. What happen is that, everytime I choose an option the page will reload then the inputs on my text field will disappear... sample HTML: <INPUT type="text" name="help_title" size="50"> <textarea...
7
37999
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific...
5
6494
by: subhodey | last post by:
Hello, I have a ColdFusion online application that has a page having 2 textboxes. Corresponding to these 2 textboxes I have a Custom tag in coldfusion where the textbox is defined by <input type=text .....>. In the onChange event a coldfusion attribute is called (like, onChange="#attributes.onChange#"). Now in the cold fusion page the 2...
3
1729
by: callre | last post by:
when i used javascript onchange() the error is coming "object doesnt support this property" my code is- <script type='text/javascript' language="javascript"> function change() { document.uplcsv.submit(); } </script>
3
4123
by: lowslyn | last post by:
hi, can someone please help me with javascript... i have this code that checks a text field when the user overrides the value to blank/space. if it is blank/space, i need to change the value to zero. it messes up the some computation when the value is blank so i need to change this to zero. what is did was to add an onchange event...
1
3135
by: paulyXvpf | last post by:
Hello javascript folks, PROBLEM: Javascript dropdown problem in IE 6 and IE7 DESCRIPTION: menu falls behind a container box on web page COMMENTS: It works fine in Firefox but not in IE 6/7 versions Notice this URL using IE6/7: http://iimaaconference.com.yourtempsite.com/
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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. ...
0
8106
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...
0
7950
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...
1
5484
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...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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
0
924
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...

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.