Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
HTML Pages with CSS and JavaScript
Radio button
Anonymous
Ranch Hand
Posts: 18944
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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>
Eric Pascarello
author
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
because you have 4 elements named the same thing so it will not work
Anonymous
Ranch Hand
Posts: 18944
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
@#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
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<form name="Form1"> <input type="radio" name="r1" onclick="enable(this,false,'cb')" onblur="enable(this,false,'cb')" checked><br/> <input type="checkbox" name="cb"><br/> <input type="checkbox" name="cb"><br/> <input type="checkbox" name="cb"><br/> <input type="checkbox" name="cb"><br/> <input type="radio" name="r1" onclick="enable(this,true,'cb')" onblur="enable(this,true,'cb')"> </form> <script type="text/javaScript"> function enable(xElem,xHow,xID){ var how = (xElem.checked) ? xHow : (xHow) ? false : true; cbElems = document.Form1[xID]; for(i=0;i<cbElems.length;i++){ cbElems[i].disabled = how; } } </script>
Anonymous
Ranch Hand
Posts: 18944
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You should
not have to do anything different by including the code as an external JavaScript file.
Anonymous
Ranch Hand
Posts: 18944
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
it says object expected!! why?
Eric Pascarello
author
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Display data from database to jsp page.
help with radio buttons
Passing check box value to servlet.
html radio button add to database
Please help me regarding the forms selection
More...