473,324 Members | 2,356 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,324 software developers and data experts.

understanding what i can do with onChange

I am pretty much a newbie with javascript, and would like to get a
little clarification on what I can do with an onChange javascript
event handler.

I have a dynamic page I build with perl and print to the browser which
includes some data displayed and edittable in <FORM> elements. There
are a couple areas where I display a message or a calculated total to
the user based on the initial values of some data elements.

I would like to clear or change the "read-only" messages and totals if
certain FORM elements get changed... and am unsure how to approach
this. It looks like if I display the "read-only" information in named
FORM elements I could use onChange event handlers to set the values...
but I don't really want the "read-only" or calculated fields to look
like regular FORM elements or allow editting.

Is there a way to use onChange to either:

- change the text in a specific area of a page that has already been
loaded using document.write() ? I am totally unsure if I have an
inline section of javascript that prints out a variable, and I change
the variable via onChange, if the text displayed would change without
refreshing the page.

- put my "calculated" values in FORM elements that look like they are
"read-only" but still allow me to change using the named object
elements?

thanks,
d
Jul 20 '05 #1
1 2572
@SM
dan baker a ecrit :

I am pretty much a newbie with javascript, and would like to get a
little clarification on what I can do with an onChange javascript
event handler.
You can change the value of a read-only field via JavaScript
Except on my NC4.5 who doesn't know what is a readonly ...!

It is the only way to do it if you don't want to re-open (and php modify)

Try that :

<html>
<form>
<p><u><b>1st test :</b></u>
<p>a "virtual read only"
<input type=text name="onlyToRead"
value="Some text to test"
onkeydown="truc=this.value;"
onkeyup="this.value=truc;">
<p>to modify the "virtual read only"
<br>Enter your text here :
<input type=text name="modificator"
onchange="onlyToRead.value=this.value;" >
and quit the field.
<hr>
<p><u><b>2nd test :</b></u>
<p>a "real read only"
<input type=text name="ToReadOnly"
value="Some text to test"
readonly>
<p>to modify the "real read only"
<br>Enter your text here :
<input type=text name="modificateur"
onchange="ToReadOnly.value=this.value;" >
and quit the field.
<hr>
<input type=reset value="Reset">
</form></html>

No, you can't document.write on a document allready open
to be compatible with old browsers you must write in text-boxes or text-areas

If old browsers are not concerned
you can use the DOM

<html>
<form>
<p>a "writter on same document" :
<input type=text name="toWrite"
onchange="if(document.getElementById)
document.getElementById('ToSee').innerHTML=this.va lue;">
<div id="ToSee"></div>
</form></html>

I have a dynamic page I build with perl and print to the browser which
includes some data displayed and edittable in <FORM> elements. There
are a couple areas where I display a message or a calculated total to
the user based on the initial values of some data elements.

I would like to clear or change the "read-only" messages and totals if
certain FORM elements get changed... and am unsure how to approach
this. It looks like if I display the "read-only" information in named
FORM elements I could use onChange event handlers to set the values...
but I don't really want the "read-only" or calculated fields to look
like regular FORM elements or allow editting.
Yes you have (ie for my NC4.5) to use regular form element.
Is there a way to use onChange to either:

- change the text in a specific area of a page that has already been
loaded using document.write() ? I am totally unsure if I have an
inline section of javascript that prints out a variable, and I change
the variable via onChange, if the text displayed would change without
refreshing the page.

- put my "calculated" values in FORM elements that look like they are
"read-only" but still allow me to change using the named object
elements?

thanks,
d


--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
************************************************** ************
Jul 20 '05 #2

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

Similar topics

2
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...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
1
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time...
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
5
by: Good Man | last post by:
Hi there I'm adding form fields on the fly with some javascript DOM programming. I basically just clone a hidden <div>, then adjust node properties to make this new <div> have unique values...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
3
by: b_naick | last post by:
I realize that the onChange event for a drop down can be trapped as follows: <select name="myDropDown" onChange="somefunc"> Is it possible to trap the onChange event outside of the select...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.