• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Radio button

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FORM action="TestList.do" method="post" name="form"

INPUT type="radio" name="qtryear" value="Qtr"
onclk ="form.chkbox1.disabled=false";

Quarter

INPUT type="checkbox" name="chkbox1" value="1-1-2001"
1st Quarter
INPUT type="checkbox" name="chkbox1" value="1-1-2002"
2nd Quarter
INPUT type="checkbox" name="chkbox1" value="1-1-2003"
3rd Quarter
INPUT type="checkbox" name="chkbox1" value="1-1-2004"
4th Quarter
BR

INPUT type="radio" name="qtryear" value="Year"
onClk="form.chkbox1.disabled=true" ;
/
Year
br
input type = submit name = submit value = submit /

/FORM


I would like to disable checkbox if type2 radio is clicked and enable check box when type1 radio is clicked.
Above code does not work why?

onClick as onclk
</FORM>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because you have 4 elements named the same thing so it will not work
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to write a function that will be called when I click on the radio.

If i click on type 1 I want to enable check box and on type 2 disable chk box.

How do I pass all the check boxes to the function at the same time

this is working ..but I would like to call a function and pass the check boxes ...

onClck=
form.chkbox1.disabled=true
form.chkbox2.disabled=true
form.chkbox3.disabled=true
form.chkbox4.disabled=true
[ September 24, 2004: Message edited by: shan javan ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@#111;nclick="document.formName.chkbox1.disabled=true;document.formName.chkbox2.disabled=true;document.formName.chkbox3.disabled=true;document.formName.chkbox4.disabled=true"


You can use the same name, but they would be an array format
chkbox1[0]
chkbox1[1]
chkbox1[2]
chkbox1[3]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FORM action="TestList.do" method="post" name = form
INPUT type="radio" name="qtryear" value="type1"
onClck="disen(form.chkbox,true)";

INPUT type="radio" name="qtryear" value="tyep2"
onClck="disen(form.chkbox,false)";

function disen (chBox,bool){
for (i=0;i<chBox.length;i++){
chBox[i].disable = bool
}
}
This code says object expected ? What is the mistake?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have your javascript stored in as abc.js

In my html I include
<script language="JavaScript" src="abc.js">
</script>

How do I pass the objects to my abc.js ?
where I have the your script

For eg document.Form1 .... works fine if both code and js are in same page.
enable(this,true,'cb')

I need to pass the this object to abc.js which is a different file.
[ September 29, 2004: Message edited by: shan javan ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should not have to do anything different by including the code as an external JavaScript file.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it says object expected!! why?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well that error means:

1- the page has not loaded completely and it is looking for the element on the page, you did not link to the js file correctly, or you included script tags inside of the js file.

Eric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic