2
   

javascript onSelect

 
 
Reply Sun 27 Mar, 2005 03:27 pm
Hi can anyone help me?

i need to write some javascript code that de-activates a group of 5 checkboxes within a <div> when a certain radio button is selected.
i think i need to use the function 'onSelect' but dont know how to use it...

Please, PLease can u help me!!!

Thanks in Advance

*T*
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 34,533 • Replies: 2
No top replies

 
jddev
 
  1  
Reply Mon 28 Mar, 2005 11:33 pm
Hey,

The onSelect function is actually triggered when a user select some text within a text or textfield area. It's not quite what you want. I would use the onClick method.

Code:
<HTML>
<HEAD>
<TITLE>Showing the script</TITLE>
<SCRIPT>

function changeBoxStatus(){
var boxes = new Array();
for (var i = 0; i < 3; i++) {
boxes[i] = document.getElementById("box"+i);

if (boxes[i].checked){
boxes[i].checked = false;
} else {
boxes[i].checked = true;
}
}
}

</SCRIPT>
</HEAD>
<BODY>

<form name="f">
<div>
1: <input type="checkbox" id="box0" checked><br>
2: <input type="checkbox" id="box1" checked><br>
3: <input type="checkbox" id="box2" checked><br>
</div>
Change boxes: <input name=someRadio type=radio onClick="changeBoxStatus()">
</form>

</BODY>
</HTML>


This piece of code will change the status of the radio boxes. Any that are checked will be unchecked and any that are unchecked will be checked. I did it this way, so you could see how to change them both ways.

The internet is an excellent tool to learn how to program such things from. As you learn the syntax and get more familiar with the code, you can find it easier and easier when you need it. Google makes an excellent tool.

Anyhow, I hope this helps.

Jason
0 Replies
 
cmpboy
 
  1  
Reply Tue 17 May, 2005 12:59 am
Hello Folks,

I have a question about JS. I am trying to achieve the following.

I have a <select> list with 4 options, A B C and D. Lets call it List1. I have a second, List2, whose values depend on List1.

Now whenever user chooses A, B or C from List1, the options in the List2 changes. I got this part working.
But i have a edit option. where I want by default selection of the options in both the lists which is going to be selected from database value.

I have called a JS function from list 1 to dynamically change values in the list 2.

& for default section I took the values directly from database & compared.
but the problem is when i want dynamic change in list2 . bydefault selection doesnt work.
Now i am not understanding what to do for making both working...


Thanks a million to whoever helps me out

computer boy
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » javascript onSelect
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/24/2024 at 04:22:13