Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12155
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: How to programmatically display a value |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <ji9bu9$l11$1@dont-email.me> |
| Message-ID | <XnsA00466F6F43C9eejj99@194.109.133.133> (permalink) |
| Date | 2012-02-25 09:07 +0000 |
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)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web