File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes refreshing the page when radio button clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "refreshing the page when radio button clicked" Watch "refreshing the page when radio button clicked" New topic
Author

refreshing the page when radio button clicked

soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
In my jsp page i have a Textfield with a dropdown and two radio button
when i select one radio button the textfield value needs to be cleared and the cursor should point in the textfield it is working fine.

But when i click another radio button the textfield value should be cleared and dropdown selected value should be cleared and needs to be disabled and the cursor should point to the textfiled

can any0ne guide me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What part are you having issues with? You can set the value of the select just as you can any other form element, and you can disable it via the disabled attribute.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
I mean to say

when i click a radio button say "No" then page is refreshing but the cursor is not pointing to a particular textfield how i need to make sure that it should point the cursor in that field
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Have you tried using the focus() method?

document.formName.elementName.focus();

Eric
soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
I tried but the focus is not coming into the textfield because the values i am inserting into the textfield are coming through (Struts action class) so the page is refreshing i am explaining the scenario what i need like


In my jsp page i had One TextField (Say: Amount) and a drop down Box (Say: Currencies) and two radio buttons (Say 1. Negative 2. Positive)

STEP: 1

By default the "Amount Field is displayed by "0" and dropdown is selected to "currency name" and "Negative" radio button is selected.
(These are by defaultly mentioned in Struts action class).

I want to validate in such a way that
If i edit the "Amount textfield" with negative value (i.e., Ex: -273) and tabbing out it should not throw an error (Ex: "Invalid data")
because the "Negative" radio button is already clicked. ( see above mentioned STEP:1)

but when you click "Positive" radio button it should through error msg "Invalid data" and also the "Drop down" what is selected should be "disabled"
and the cursor should focus on the "AMount" textfield

If i enter "Positive value" in "AMount field" (Ex: 233) when "Positive radio button" is selected it should not through error message
if i select "Negative Radio button" then "Drop down" should be enabled and the cursor should point to the "Amount Field".

Note: the values should not be cleared in the "Amount textfield" in any of the scenarios
it should not take any invalid special characters say "@#$!*&^" etc.,

can any body suggest me to implement by giving example
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: refreshing the page when radio button clicked
 
Similar Threads
returning to the previous page with cleared GUI components
get the radio button value in three differnt jsp
JSP and Radio Buttons
page state is getting lost when back button is clicked
validating textfield with +ve/-ve values using 2 radiobuttons