Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 12-18-2002, 07:20 AM form and javascript
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
how do i say

that if a checkbox is checked do this,

else do this

basically what i want is i have a checkbox, which if it is checked will display a text

if it is not cheked will display another message.


i tried but it is giving me errors


thanks
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-18-2002, 07:57 AM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Trades: 0
Hi praveen,

I am not very familiar with JavaScript, but this is how it is done in VBScript.

PHP Code:
<form name=checkbox>
<
input type="check">
</
form>
<
script language="VBScript">
if 
document.checkbox.elements(0).Checked Then
   alert 
"Message 1"
else
   
alert "Message 2"
</script> 
It might be something similar in JavaScript. Do remember that when verifying whether a checkbox/radio button is checked, you MUST refer to the element number. You cannot refer to it using the assigned "value".
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile
 
Old 12-18-2002, 06:38 PM
dk01's Avatar
Ultra Talker

Posts: 373
Location: Ames, IA
Trades: 0
In js:
PHP Code:
if(document.myform.mycheckbox.checked) {
   
alert("The element is checked.");
} else {
      
alert("The element is not checked");

Just replace myform with the name of your form and mycheckbox with the name of your text box.
-dk
__________________
Did I help you? If so, be nice and throw me some
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by dk01; 12-18-2002 at 06:41 PM..
dk01 is offline
Reply With Quote
View Public Profile
 
Old 12-19-2002, 03:27 AM
xtravel's Avatar
Super Talker

Posts: 125
Location: Maldives
Trades: 0
hey,

visit http://javascript.internet.com/ this place have a lot of useful free javascripts.

chao, xtravel
__________________
See the unique beauty of Maldives, Visit
Please login or register to view this content. Registration is FREE
xtravel is offline
Reply With Quote
View Public Profile
 
Old 12-19-2002, 03:58 AM
dk01's Avatar
Ultra Talker

Posts: 373
Location: Ames, IA
Trades: 0
Yes but it is better to write your own javascript! Its fun and a good way to learn some programming basics before moving on to a major langauge.
-dk
__________________
Did I help you? If so, be nice and throw me some
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
dk01 is offline
Reply With Quote
View Public Profile
 
Old 12-19-2002, 10:09 AM
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
firstly,
thanks ppl.

what i am looking for and want is.

i have a checkbox and a "hidden layer" beneath it.

so whenever someone checks the box, it should be visible.
this part is fine and works.

but when someone unchecks it, the layer should disappear.

how do you do this..




here is the code.

Quote:
this is the style denition

.message {visibility: hidden;}

here is the script..

function toggle(e) {
if (e.style.display == "none") {
e.style.display = "";
} else {
e.style.display = "none";
}
}


and here is the checkbox
<form>
<input type="checkbox" id="checkbox" onclick=toggle(message)" ></form>

here is the div..

<div id="message"> test the message script.</div>

what is happening is, this script overrides the style settings for the message div and displayes it.. when the checkbox is checked it disappears..

but what i want is the other way round.

when the checkbox is checked, it should appear..

how do i do it..???
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by praveen; 12-19-2002 at 12:17 PM..
praveen is offline
Reply With Quote
View Public Profile
 
Old 12-21-2002, 04:37 AM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Trades: 0
Quote:
Originally posted by dk01
Yes but it is better to write your own javascript! Its fun and a good way to learn some programming basics before moving on to a major langauge.
-dk
I find it especially enjoyable to program, except I personally find VBScript easier than JavaScript.
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile
 
Old 12-22-2002, 05:54 PM
dk01's Avatar
Ultra Talker

Posts: 373
Location: Ames, IA
Trades: 0
conkermaniac:
Yeah vbscript is nice if it was supported by more browsers than just ie. I am assuming you do vb normally? I love vb but have recently gotten into c++'s object oriented progamming stuff and it quite useful.

praveen:
Check out this tutorial I wrote about the subject of hiding and showing layers (<div> or <span>):
http://www.conxiondesigns.com/tutorials/hideshow/
If you have any problems with it just let me know.
-dk
__________________
Did I help you? If so, be nice and throw me some
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by dk01; 12-23-2002 at 04:31 AM..
dk01 is offline
Reply With Quote
View Public Profile
 
Old 12-23-2002, 05:45 AM
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
Thank You DK


i was looking for asomething like this only. thanks a lot.

and merry christmas to all.. and a happy new year
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 12-23-2002, 09:38 AM
dk01's Avatar
Ultra Talker

Posts: 373
Location: Ames, IA
Trades: 0
No probs. Same to you. Merry xmas.
-dk
__________________
Did I help you? If so, be nice and throw me some
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
dk01 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to form and javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30148 seconds with 12 queries