Jump to content

clear a listbox when another listbox selected on click of radio button


pacesenthil
 Share

Recommended Posts

I have created a radio button on click listbox will display now if user click a one radio button listbox value will display in table but again user select other option at that time it displaying same table with same value so its not clear a previous value of listbox value ...so i have thougth that to clear full listbox value or listbox???

<script language="JavaScript" type="text/javascript">function fun(s){if(s=={document.getElementById("maingroup").style.display='none';document.getElementById("subgroup").style.display='';document.getElementById("itemname").style.display='none';}if(s==C){document.getElementById("maingroup").style.display='none';document.getElementById("subgroup").style.display='none';document.getElementById("itemname").style.display='';}</script>

here is the full example in Jsfiddle

http://jsfiddle.net/senthil4040/LUY3J/

 

 

kindly help on this Am new to script????

Edited by pacesenthil
Link to comment
Share on other sites

hiding a selection doesn't make it forget what option you've selected for that select tag. style.display only affects the visual presentation of the object. your browser will still remember what you chose even if you hide it like that.

 

I rewrote your code in this fiddle with a little cleaner html and javascript

Edited by Hadien
Link to comment
Share on other sites

thanks for effort Hadien...i will follow that....

Let i explain clearly

Top row :main group,sub group,item name

bottom row:country,zone,state,...etc....

 

now user can select any one in top and below is mandatory ...but now according to radio button list box value will display correctly but if i select MAIN-GROUP AND COUNTRY ..pass value displaying value in table correctly again if i select MAIN-GROUP and STATE pass value at the time also MAIN-GROUP AND COUNTRY value only displaying in table .....so i preferred to go depending on selection other to be clear.....or to set some null value ....???

 

and other thing is if i select MAIN-GROUP AND COUNTRY ..correctly display value in table again if i select MAIN-GROUP and STATE

if i set manually to NULL VALUE to country then correctly display for MAIN-GROUP and STATE ..so user cant set null value to each list box so only go for clear it...

 

am new to script sorry for my bad English .......

Edited by pacesenthil
Link to comment
Share on other sites

I am sorry, but I couldn't understand what you were trying to say in that post. Perhaps if you wrote in steps with simple sentences what you do to the program then what you expect the program to do like i describe below.

1). User:    Select MAIN-GROUP and COUNTRY radio buttons.    Program: Display select boxes for MAIN-GROUP and COUNTRY. 2). User:     Select option in COUNTRY select menu.    Program:  Update COUNTRY select menu to the selected option. 3). User:    Select STATE radio buton.    Program: Hide COUNTRY select menu.             Prevent user the ability to reselect the COUNTRY menu             Display select menu for STATE.
Link to comment
Share on other sites

sorry for late reply am out of town ...let i try to explain the thing is normally i entered into java script by the element of ID or NAME now am dealing with SELECT without OPTGROUP......depending on radio button list box have to display other to be clear or remove in browser

 

1). User:    Select MAIN-GROUP and COUNTRY radio buttons.    Program: Display select boxes for MAIN-GROUP and COUNTRY.function: Display Some data for MAIN-GROUP and COUNTRY2) User:    Select MAIN-GROUP and STATE radio buttons.   Program: Display select boxes for MAIN-GROUP and STATE.function: Display Some data for MAIN-GROUP and STATE but notPROBLEM: IF i select from MAIN-GROUP and STATE DISPLAYING a Data for MAIN-GROUP and COUNTRY only...Reason: It's not clear a previous option of MAIN-GROUP and COUNTRY list box Value so i tried to remove option temporarily ..in browser. SOLUTION:: if i set NULL VALUE manually to each selection before other selection it will display a correct data ...so user can't set null value before other selection so the solution is to clear a value or remove option temporarily...in browser
Edited by pacesenthil
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...