472,992 Members | 3,316 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

Newby level question: Radio Buttons

Hello,

I have a web page that gets the user to select items from a list of options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the possibility of multiple selections. However, one item is "None of the above" and I have placed some logic (autopostback, etc.) that will remove all previous selections if "None of the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with AutoPostback enabled (and someone selects one of these Radio Buttons) the web browser refreshes the screen and shows the top of the page. What can I do such that the screen refreshes and displays the bottom portion with the Radio Buttons? Or is there a way to do what I want to do without using AutoPostback?

TIA...
Nov 19 '05 #1
3 2423
Ferret Face,

You could try out setting the page's Smart Navigation property to true. Smart navigation keeps the screen position during post backs. But it doesn't work for any browser (that I know of) except IE and it can cause flaky behaviour.

Because of this I created a javascript that will automatically scroll a page to whatever control you specify as a reusable object. Actually the javascript object contains many useful scripts.

You can download the Javascript component I built for free with full source code as a VS2003 project from my website, www.aboutfortunate.com. Also download the .chm help file. It gives help for every control I've created all of which are downloadable from my site for free with full source.

To get the javascript component click the "Code Library" link at the top of my page and then click the "Javacript" button on the left.

You'll want to use the "ScrollToElement" method of the component.

If you have any questions about the component or use thereof feel free to email me.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ferret Face" <fe********@msn.com> wrote in message news:Lv********************@giganews.com...
Hello,

I have a web page that gets the user to select items from a list of options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the possibility of multiple selections. However, one item is "None of the above" and I have placed some logic (autopostback, etc.) that will remove all previous selections if "None of the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with AutoPostback enabled (and someone selects one of these Radio Buttons) the web browser refreshes the screen and shows the top of the page. What can I do such that the screen refreshes and displays the bottom portion with the Radio Buttons? Or is there a way to do what I want to do without using AutoPostback?

TIA...
Nov 19 '05 #2
One solution is to enable SmartNavigation, although there are a lot of
reasons not to do so
(http://weblogs.asp.net/ksamaschke/ar...4/27/6085.aspx,
http://weblogs.asp.net/dreilly/archi...14/229424.aspx

Alternatively, you might want to take a look at the free (but no source
code) Smart Scroller:
http://www.strengthtechnologies.com/scroll/

Finally, you can likely achieve all that you want in JavaScript if that's
acceptable. Here's a quick example, might not work but should give you an
idea...

<div id="choices">
<input type="Radio" name="1" value="choice1">
<input type="Radio" name="2" value="choice2">
<input type="Radio" name="3" value="choice3">
<input type="Radio" name="4" value="choice4">
<input type="Radio" name="5" value="none" onClick="Clicked('choices',
this);">
</div>

<script language="JavaScript">
function Clicked(containerName, source)
{
var container = document.getElementById(containerName);
if (!container){
//something went wrong
return;
}
var inputs = container.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; ++i)
{
var input = inputs[i];
//if we have a radiobutton (we don't want to disable a textbox in here
too, or do we?) AND we aren't on the "none" button
if (input.type.toUpperCase() == "RADIO" && input.value != "none")
{
input.disabled = source.checked; //if our non button is checked, the
input is disabled, if it isn't checked, it's enabled.
}
}
}
</script>
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Ferret Face" <fe********@msn.com> wrote in message
news:Lv********************@giganews.com...
Hello,

I have a web page that gets the user to select items from a list of
options. This list is a set of independant Radio Buttons. I did not use a
Radio Button List because I wanted the possibility of multiple selections.
However, one item is "None of the above" and I have placed some logic
(autopostback, etc.) that will remove all previous selections if "None of
the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with
AutoPostback enabled (and someone selects one of these Radio Buttons) the
web browser refreshes the screen and shows the top of the page. What can I
do such that the screen refreshes and displays the bottom portion with the
Radio Buttons? Or is there a way to do what I want to do without using
AutoPostback?

TIA...
Nov 19 '05 #3
Hey! Who you callin' Ferret Face?!
.... Wait, that's my name.

That JavaScript did the trick. I had to brush-up on JavaScript a bit to
do it. I ended up changing the line

if (input.type.toUpperCase() == "RADIO" && input.value != source.value)

to make it work.

Thanks!
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
One solution is to enable SmartNavigation, although there are a lot of
reasons not to do so
(http://weblogs.asp.net/ksamaschke/ar...4/27/6085.aspx,
http://weblogs.asp.net/dreilly/archi...14/229424.aspx

Alternatively, you might want to take a look at the free (but no source
code) Smart Scroller:
http://www.strengthtechnologies.com/scroll/

Finally, you can likely achieve all that you want in JavaScript if that's
acceptable. Here's a quick example, might not work but should give you an
idea...

<div id="choices">
<input type="Radio" name="1" value="choice1">
<input type="Radio" name="2" value="choice2">
<input type="Radio" name="3" value="choice3">
<input type="Radio" name="4" value="choice4">
<input type="Radio" name="5" value="none" onClick="Clicked('choices',
this);">
</div>

<script language="JavaScript">
function Clicked(containerName, source)
{
var container = document.getElementById(containerName);
if (!container){
//something went wrong
return;
}
var inputs = container.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; ++i)
{
var input = inputs[i];
//if we have a radiobutton (we don't want to disable a textbox in here
too, or do we?) AND we aren't on the "none" button
if (input.type.toUpperCase() == "RADIO" && input.value != "none")
{
input.disabled = source.checked; //if our non button is checked, the
input is disabled, if it isn't checked, it's enabled.
}
}
}
</script>
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Ferret Face" <fe********@msn.com> wrote in message
news:Lv********************@giganews.com...
Hello,

I have a web page that gets the user to select items from a list of
options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the possibility of multiple selections.
However, one item is "None of the above" and I have placed some logic
(autopostback, etc.) that will remove all previous selections if "None of
the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with
AutoPostback enabled (and someone selects one of these Radio Buttons) the
web browser refreshes the screen and shows the top of the page. What can I do such that the screen refreshes and displays the bottom portion with the
Radio Buttons? Or is there a way to do what I want to do without using
AutoPostback?

TIA...

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
1
by: Brian Henry | last post by:
In standard VB.NET you can group radio buttons in a pannel or frame and when you click on one in that frame or pannel the others will update relative to the selection so only the one you picked is...
1
by: Jay | last post by:
I need to validate 21 sets of radio buttons before submission to the server for calculation and storage. Is it best to validate on the client side using javascript or to validate on the server...
3
by: Ken Varn | last post by:
This is probably a simple question, but I am new to this so bear with me. I have a ASP.NET form that has a checkbox and a 2 radio buttons. When the checkbox is checked, the 2 radio buttons are...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
12
html on wheels
by: html on wheels | last post by:
Greeting sports fans. In order to ask multiple questions and not have your radio buttons jump from one question to the next, what do you type to create a break between them. I am trying to complete a...
3
by: SAM | last post by:
ll a écrit : <script type="text/javascript"> function checkform( f ) // f is the form to check { var txt1 = 'Please make a selection for the Learning Outcome :', txt2 = '\nYour...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.