Click to See Complete Forum and Search --> : Dynamic Text Boxes in Form


gaalaant
02-27-2010, 01:54 PM
Hi,

Would it be possible to use a value in a form text box to hide/show additional text boxes in that form? Meaning, if a user enters a value into a text box of 1 (default is 0), then another text box pops up.

I guess I cant use server-side processing because I would like this behavior to occur without the submit button being pressed. Is java the only option?

I guess my major confusion is how to get the value entered by the user out of the text box without the entire form being submitted. I mean, if the form is submited and the user has navigated away, i can retrieve the value entered from the database, but I would like to show other options dynamically when a value is keyed in but before a button is pressed.

thanks.

gaalaant
03-03-2010, 09:49 PM
Does anyone have any advice? I dont understand, is this complicated or is it that im phrasing my question in such a way that discourages comment?

ryanbutler
03-04-2010, 09:13 AM
I don't understand the intent to what you're trying to do?

aj_nsc
03-04-2010, 09:33 AM
Judging by your assumption that 'Java' is the only option, you probably don't have too much experience with Javascript (the client-side language that you actually need to use).

It's actually quite easy to do, if you have decent knowledge of Javascript. Procedurally, you'd do it like this:

1) When a user enters something in a textbox, get it's value (using an onchange listener)
2) Determine what you need to do (add/remove a field) based on the value entered
3) Add or Remove the field by either a) creating it and appending it to your form using Javascript, or, if you already have the element in the form, just hidden from view using CSS, use Javascript to display it.

You might want to start asking around the Javascript forum.