PDA

View Full Version : How to dynamically update text without refreshing page?


BigDaddy
10-02-2002, 04:41 PM
Ok....

I have a form with a set of radio buttons, and a few text boxes. I want to update the text that is being printed out at the bottom of the page, kind of a summary of the values selected in the form elements above. Currently, I have a text box, and I'm using an onchange, or onblur event for the elements, which calls a function to change the value of the text boxes below.

Does anyone know of anyway to change this text without using a textbox?

adios
10-02-2002, 05:07 PM
If you don't find something useful here, I'd be surprised...


http://www.dyn-web.com/

ASAAKI
10-02-2002, 05:11 PM
well, if ur main problem is that u don't want it to show, u cud just use <input type="hidden"> instead of <input type="text"> ... or did i not get ur point?

whammy
10-03-2002, 01:50 AM
He got it figured out. Thread closed... but thanks for the offered help!

Doh... I'm not the moderator in this forum. LOL.

BigDaddy
10-03-2002, 02:29 AM
Thanks for the input guys. What I ended up doing was using a textbox, but used CSS to set the border of the textbox to none.

I then was able to dynamically change the value of the textboxes. You can't even tell the textbox is there until I set the value to something.

whammy
10-03-2002, 02:35 AM
That's a perfect explanation... basically you use CSS with no borders on a text field, etc. so the user can't actually discern it's really a form field instead of a layer... I'm surprised I didn't think of that. :D

glenngv
10-03-2002, 07:06 AM
Originally posted by BigDaddy
Thanks for the input guys. What I ended up doing was using a textbox, but used CSS to set the border of the textbox to none.

I then was able to dynamically change the value of the textboxes. You can't even tell the textbox is there until I set the value to something.

you can use a <div> tag instead of textbox.
change its value by:

document.getElementById("IDofDiv").innerHTML="some text here";

jmooring
04-20-2006, 06:24 AM
Similar situation where I've read a value into a text field and can reference that value through a javascript, but I'd rather reference that same value from text set into a DIV layer. Does that make sense?

More specifically, I'll be passing along that value as part of a PayPal variable on submission of a form.

Thanks for any guidance.

Kor
04-20-2006, 06:44 AM
you may reference a text nested into a DIV layer (or whichever tag which support textNode as child) you may use

var myText = document.getElementById('mydiv').innerHTML
var myText = document.getElementById('mydiv').firstChild.data
var myText = document.getElementById('mydiv').firstChild.nodeValue

Caution. If the DIV nests a coumpounded data (mixture of HTML tags and text)

<div id="mydiv">this is the <strong>bold</strong> and <em>italic</em></div>

the problem becomes a little bit more intricate but not impossible. innerHTML will return the tags as well, as string, while DOM methods data and nodeValue will reurn only the firstChild ('this is the ' string, in my example) data.

It depends, thus, of the nature of the inner tag space.