By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Manipulating form elements

P: n/a
I'm trying to modify a form so that when a user clicks a checkbox for a
shorter version of the form, it will replace swap the default (long)
form elements with the short version of elements, so that only the
version that is selected will have its element values passed on to the
next page.

Currently I have two div areas set up with ids as such:

<script>
javascript..
</script>

<form>
<checkbox id="version_check" name="version check">
^ Checkbox for whether user wants long or short version of form
<div id="form_area">
the form elements that would be modified
</div>
</form>

<div id="option 1" style="visibility: hidden">
The long version of form elements
</div>
<div id="option 2" style="visibility: hidden">
The short version of form elements
</div>

So as you can see, the idea is to have two divs (which are basically
just variable containers) holding the possible format of the form. I
want javascript to default to option 1 and when the checkbox is checked
to display option 2. If the user unchecks the box, it should go back
to option 1.

I have been playing around with js code for a while now and cannot get
it to work. Anyone want to try their hand with this? I can post my
code, but figured the above explanation may be cleaner than seeing my
hacked up code.

If this is not such a hot idea for what I'm trying to do, please feel
free to let me know a more efficient way to handle this.

Thanks in advance!

Oct 4 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> "jingalls" <jr*******@gmail.com> wrote:
news:11**********************@g14g2000cwa.googlegr oups.com....

I'm trying to modify a form so that when a user clicks a checkbox
for a shorter version of the form, it will replace swap the
default (long) form elements with the short version of elements,
so that only the version that is selected will have its element
values passed on to the next page.

Currently I have two div areas set up with ids as such:

<snip>

So as you can see, the idea is to have two divs (which are
basically just variable containers) holding the possible format of
the form. I want javascript to default to option 1 and when the
checkbox is checked to display option 2. If the user unchecks the
box, it should go back to option 1.

I have been playing around with js code for a while now and cannot
get it to work. Anyone want to try their hand with this? I can post
my code, but figured the above explanation may be cleaner than
seeing my hacked up code.

If this is not such a hot idea for what I'm trying to do, please
feel free to let me know a more efficient way to handle this.

Thanks in advance!

Not knowing how much differance there is between the short version
and the long verison I would likely make two complete forms, and just
display the one that has been chosen. I would also likely make the
long version the default form just incase there be no javascript.

--
BootNic Tuesday, October 04, 2005 8:04 PM

Optimism and humor are the grease and glue of life. Without both of them we would never have
survived our captivity.
*Philip Butler, Vietnam POW*
Oct 5 '05 #2

P: n/a
Ok, that makes sense, basically just create divs with complete forms
and based on what the state of the check box is, display form x.

Now all I have to do is make sure the div shows up in the right place.

Thanks

Oct 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.