I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with
JavaScript?
Thanks!! 10 1617
Easiest way would be to put the 2 new fields in block elements like
divs, set their initial style to
display:none, then with the radio buttons have an onclick event handler
that sets the appropriate div to display:block and the other div to
display:none. Then there is no refreshing required.
Jen wrote:
>
I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with
JavaScript?
Thanks!!
You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.
The problem with using "display: none" is that even though it's
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.
DOM scripting is the way to go. You have full control over many things.
Gary Hasler wrote:
Easiest way would be to put the 2 new fields in block elements like
divs, set their initial style to
display:none, then with the radio buttons have an onclick event handler
that sets the appropriate div to display:block and the other div to
display:none. Then there is no refreshing required.
Jen wrote:
I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with
JavaScript?
Thanks!!
Matthom wrote:
Top posting on top posting, please don't!
Gary Hasler wrote:
>>Jen wrote:
>>>I have a form that has two radio buttons. When the first one is clicked, I would like the page to refresh (keeping the form data in tact) and then displaying 2 new fields that need to be filled out. If the second button is clicked, I need the same thing to happen, only it will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with JavaScript ?
Easiest way would be to put the 2 new fields in block elements like divs, set their initial style to display:non e, then with the radio buttons have an onclick event handler that sets the appropriate div to display:block and the other div to display:non e. Then there is no refreshing required.
You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.
The problem with using "display: none" is that even though it's
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.
No, "display: none" removes the element form the page.
DOM scripting is the way to go. You have full control over many
things.
It's easier just to use a visible and invisible CSS class and swap the
element's class name.
--
Ian Collins.
Matthom wrote:
The problem with using "display: none" is that even though it's
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.
No, if it's set to "display:no ne" it should not take space in the layout
at all. The rest of the page should slide up/down as it is shown or
hidden.
On 2006-10-04 21:48:32 +0200, "Jen" <je*******@reve aled.netsaid:
I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact)
Doing this by "refreshing " the page is a server-side, extremely
inefficient, and long outdated method.
You don't want the page to refresh. You want to update part of it, and
if I understand correctly, you don't need to retrieve data from the
server.
and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.
The best way to do this would be:
- add 2 divs just below the radio buttons, each of them containing the
2 extra fields for one of the radio buttons. Do this in pure HTML, this
content should not be generated by JavaScript (that way, it remains
accessible, and it's easier to use anyway). Of course, if there were a
large or undetermined number of additional fields, you would have to
generate them dynamically.
- give each div and radio an id so you can grab them in the script. For
example, the radios have the ids "rad1" and "rad2" and the divs "div1"
and "div2".
- dynamically hide or show the divs when the user toggles the radio
buttons. That can be done in JavaScript with something like this:
with({ // just setting some private shortcuts.
r1:document.get ElementById("ra d1"),
r2:document.get ElementById("ra d2"),
d1:document.get ElementById("di v1"),
d2:document.get ElementById("di v2")})
{
// initially the divs should be hidden
d1.style.displa y=d2.style.disp lay="none"
// radios can be switched with the mouse or keyboard
// so we handle both events
r1.onclick=r2.o nclick=r1.onkey down=r2.onkeydo wn=
function (e)
{
var s=["none","blo ck"]
// show the div if the corresponding radio
// is turned on
d1.style.displa y=s[r1.checked]
d2.style.displa y=s[r2.checked]
}
}
--
David Junger
Thanks everyone!
I have found a piece of code that works beautifully:
function delay() {
setTimeout('tog gle()','200');
}
function toggle() {
if (document.getEl ementById('cont ribution').chec ked === true) {
document.getEle mentById('divYe s').style.displ ay = "block"
document.getEle mentById('divNo ').style.displa y = "none"
} else {
document.getEle mentById('divYe s').style.displ ay = "none"
document.getEle mentById('divNo ').style.displa y = "block"
}
}
<style type="text/css">
#divYes { display:none }
#divNo { display:none }
</style>
<body>
<p onmouseup="dela y();"><input type="radio" name="contribut ion"
id="contributio n" /Show<br />
<input type="radio" name="contribut ion" id="contributio n" /Hide</p>
<div id="divYes">
<p>Content.Ye s</p>
<p>Content.Ye s</p>
</div>
<div id="divNo">
<p>Content.No </p>
<p>Content.No </p>
</div>
</body>
Thanks!
Touffy wrote:
On 2006-10-04 21:48:32 +0200, "Jen" <je*******@reve aled.netsaid:
I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact)
Doing this by "refreshing " the page is a server-side, extremely
inefficient, and long outdated method.
You don't want the page to refresh. You want to update part of it, and
if I understand correctly, you don't need to retrieve data from the
server.
and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.
The best way to do this would be:
- add 2 divs just below the radio buttons, each of them containing the
2 extra fields for one of the radio buttons. Do this in pure HTML, this
content should not be generated by JavaScript (that way, it remains
accessible, and it's easier to use anyway). Of course, if there were a
large or undetermined number of additional fields, you would have to
generate them dynamically.
- give each div and radio an id so you can grab them in the script. For
example, the radios have the ids "rad1" and "rad2" and the divs "div1"
and "div2".
- dynamically hide or show the divs when the user toggles the radio
buttons. That can be done in JavaScript with something like this:
with({ // just setting some private shortcuts.
r1:document.get ElementById("ra d1"),
r2:document.get ElementById("ra d2"),
d1:document.get ElementById("di v1"),
d2:document.get ElementById("di v2")})
{
// initially the divs should be hidden
d1.style.displa y=d2.style.disp lay="none"
// radios can be switched with the mouse or keyboard
// so we handle both events
r1.onclick=r2.o nclick=r1.onkey down=r2.onkeydo wn=
function (e)
{
var s=["none","blo ck"]
// show the div if the corresponding radio
// is turned on
d1.style.displa y=s[r1.checked]
d2.style.displa y=s[r2.checked]
}
}
--
David Junger
Actually posting on top is what most groups application do for us...
rightly so too. There's NOTHING more annoying then someone reply
weaving in and out of a message... it's nearly impossible to find what
someone is saying.
EOT.
Ian Collins wrote:
Matthom wrote:
Top posting on top posting, please don't!
Gary Hasler wrote:
>Jen wrote:
I have a form that has two radio buttons. When the first one is clicked, I would like the page to refresh (keeping the form data in tact) and then displaying 2 new fields that need to be filled out. If the second button is clicked, I need the same thing to happen, only it will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with JavaScript?
Easiest way would be to put the 2 new fields in block elements like divs, set their initial style to display:none , then with the radio buttons have an onclick event handler that sets the appropriate div to display:block and the other div to display:none . Then there is no refreshing required.
You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.
The problem with using "display: none" is that even though it's
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.
No, "display: none" removes the element form the page.
DOM scripting is the way to go. You have full control over many
things.
It's easier just to use a visible and invisible CSS class and swap the
element's class name.
--
Ian Collins.
Actually posting on top is what most groups application do for us...
rightly so too. There's NOTHING more annoying then someone reply
weaving in and out of a message... it's nearly impossible to find what
someone is saying.
EOT.
Ian Collins wrote:
Matthom wrote:
Top posting on top posting, please don't!
Gary Hasler wrote:
>Jen wrote:
I have a form that has two radio buttons. When the first one is clicked, I would like the page to refresh (keeping the form data in tact) and then displaying 2 new fields that need to be filled out. If the second button is clicked, I need the same thing to happen, only it will display two different fields needing to be filled out.
Does anyone have code that will do this? Or is this even possible with JavaScript?
Easiest way would be to put the 2 new fields in block elements like divs, set their initial style to display:none , then with the radio buttons have an onclick event handler that sets the appropriate div to display:block and the other div to display:none . Then there is no refreshing required.
You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.
The problem with using "display: none" is that even though it's
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.
No, "display: none" removes the element form the page.
DOM scripting is the way to go. You have full control over many
things.
It's easier just to use a visible and invisible CSS class and swap the
element's class name.
--
Ian Collins.
ag******@gmail. com wrote:
Actually posting on top is what most groups application do for us...
No it isn't. It is also considered rude in most technical news groups.
--
Ian Collins. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: George Adams |
last post by:
I like the idea of compiling DSO modules for Apache. It allows me to turn
on or off things we may or may not need at a given time (like mod_ssl,
mod_auth_mysql, mod_auth_ldap, etc.) and also allows me to compile in new
versions of modules without having to rebuild Apache from scratch.
Now, when I build PHP, I tend to put in a lot of things. Like:
|
by: mr_burns |
last post by:
hi,
is it possible to change the contents of a combo box when the contents
of another are changed. for example, if i had a combo box called
garments containing shirts, trousers and hats, when the user selects
shirts another combo box called 'size' would contain sizes in relation
to shirts (ie. chest/neck size). the same would occur for trousers and
hats. when the user selects an option in the garment combo box, the
options available...
|
by: Mark |
last post by:
Hello,
I have a database which contains approximately 30 reference tables.
I've been looking at building a dynamic datagrid that is updateable,
but have run into problems with the Cancel and Update events not
firing. After reading several posts about the events not firing, it
seems that this may not be the best solution.
What would be the best way to handle the updates of the 30 tables?
Should I build one page with 30 datagrids and...
|
by: sleigh |
last post by:
Hello,
I'm building a web application that will build a dynamic form based
upon questions in a database. This form will have several different
sections that consist of a panel containing one to many questions.
To keep it simple, I'll describe the basics of what I'm trying to
design.
I've created a TextBox composite control that consists of a label for
|
by: brian |
last post by:
I am looking at purchasing or creating a dynamic
navigational menu system that would be binded to SQL
server 2000 data. The users id is stored in the SQL
server and based on the id is what the navigational menu
would show.
I would perfer to gain the experieance of building it
myself but theres not much documentation out there on
that subject. If anyone has any please guide me to it.
| |
by: moondaddy |
last post by:
I'm writing an ecommerce app in asp.net/vb.net and need to make the pages
searchable and crawlable by spiders, particularly Google's. As far as I
know, if my pages's contents are mostly populated by user controls on a
single page and I call these different controls by passing one or more
parameters like this: myweb.com/default.aspx?MenuID=44, then the spiders
aren't going to be able do to anything with this. asp.net offers lots of
great...
|
by: Brian Shannon |
last post by:
I have 3 combo boxes and two date text boxes on a .aspx page. The user can
fill in any of the 5 controls or none to filter a datagrid. I was hoping
someone could explain how to efficiently build the where clause of a sql
string to send to SQL 2000 for a data set.
Currenly I check each control with an IF statement to determine if something
is filled in. If there is I begin building the where clause. Below is what
I have done (and it...
|
by: Leo J. Hart IV |
last post by:
OK, here's another question for the experts:
I am building a multi-step (3 steps actually) form using a panel for
each step and hiding/displaying the appropriate panel/panels depending
on which step you're on. This all works fine, but I ran into some
trouble when I started creating controls dynamically in my code-behind
file.
Each panel contains a table which is filled with various radio buttons,
text fields and the such which are...
|
by: Larry Grady |
last post by:
Anyone up for a challenge?
I've been struggling with this for a few days and was hoping someone could
help me. Pouring through all the messageboards I just can't find the
solution.
We have a GridView that needs to be dynamically designed, depending on what
collection of fields our uses want to edit for their product data. We have
400+ fields of information per product so they're selecting a subset of those
fields to edit.
|
by: englishman69 |
last post by:
Hello,
I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final postback to enter the values in the dynamic textboxes into the database the values seem to become...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |