Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12140 > unrolled thread
| Started by | " Cal Who" <CalWhoNOSPAM@roadrunner.com> |
|---|---|
| First post | 2012-02-24 20:01 -0500 |
| Last post | 2012-02-25 09:07 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.javascript
How to programmatically display a value " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 20:01 -0500
Re: How to programmatically display a value Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-25 01:08 +0000
Re: How to programmatically display a value "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-25 09:07 +0000
| From | " Cal Who" <CalWhoNOSPAM@roadrunner.com> |
|---|---|
| Date | 2012-02-24 20:01 -0500 |
| Subject | How to programmatically display a value |
| Message-ID | <ji9bu9$l11$1@dont-email.me> |
I calculate and want to display the numerical result. I can do it by assigning to the value attribute of an <input type=text> element. However, I don't want the user to be able to change the value displayed. I tried readonly="readonly" but, unless I had a bug in the code, I found I couldn't programmatically change the value displayed by assigning to value. How should I do that? Thanks
[toc] | [next] | [standalone]
| From | Mike Duffy <Use_guestbook_page@website.in.sig> |
|---|---|
| Date | 2012-02-25 01:08 +0000 |
| Message-ID | <XnsA003CCDC17099invalidcom@94.75.214.39> |
| In reply to | #12140 |
" Cal Who" <CalWhoNOSPAM@roadrunner.com> wrote in
news:ji9bu9$l11$1@dont-email.me:
Define an element, using HTML such as:
Blah blah <span id="xyz">this text can change</span> Yadda yadda.
In your javascript, you have a statement like:
var elTest = document.getElementByID("xyz");
elTest.innerHTML = "new stuff";
--
http://pages.videotron.ca/duffym/index.htm
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-02-25 09:07 +0000 |
| Message-ID | <XnsA00466F6F43C9eejj99@194.109.133.133> |
| In reply to | #12140 |
Cal Who wrote on 25 feb 2012 in comp.lang.javascript: > I calculate and want to display the numerical result. > > I can do it by assigning to the value attribute of an <input > type=text> element. That can be done, but why fool your users by using output into an input element, UNLESS you want your users to be able to change it before submission? Better [sorry] use a simple display-element like <div> or <span> and .innerHTML > However, I don't want the user to be able to change the value > displayed. > > I tried readonly="readonly" but, unless I had a bug in the code, I > found I couldn't programmatically change the value displayed by > assigning to value. you must have made a mistake, meseems, it can be done. or if this result only needs to be submitted, use an hidden input element. > How should I do that? <input type='hidden' name='myHidden'> document.forms.0.elements.myHidden.value = myResult; or inside the form: <input type='hidden' name='myHidden'> <input type='button' onclick = 'this.form.elements.myHidden.value = myResult;' value='touch me'> so: The content of a form element is accessed by .value the content of display elements by .innerHTML. [or use DOM-tree methods] -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web