Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 18th, 2003, 12:06 PM
snoopy27 snoopy27 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 4 snoopy27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Radio Buttons Default value

Would like to know how to set a default value of a radio button.
I'm able to set it on the click of a button but not while the page is initially loading.

Code:
<SCRIPT LANGUAGE="javascript">
document.form.room[1].checked=true;
</SCRIPT>

<form name="form">
<INPUT TYPE="RADIO" NAME="room" VALUE="Test"> Test
<INPUT TYPE="RADIO" NAME="room" VALUE="Cream"> Cream
<INPUT TYPE="RADIO" NAME="room" VALUE="Red">Red
</form>


On loading this page I would like Cream to be checked. How can I do that? document.form.room[1].checked=true; is not working!

Thanks

Reply With Quote
  #2  
Old March 18th, 2003, 01:11 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
<INPUT TYPE="RADIO" NAME="room" VALUE="Red" CHECKED>Red

__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old March 18th, 2003, 02:47 PM
snoopy27 snoopy27 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 4 snoopy27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

But that would mean that its static, 'Red' would be checked everytime the page is loaded? What if I was to check the radio button depending on some value that was entered in the previous page?


Reply With Quote
  #4  
Old March 18th, 2003, 04:00 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 20 m 5 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
and what are you using to handle what was entered in the previous page?

Reply With Quote
  #5  
Old March 19th, 2003, 07:09 AM
snoopy27 snoopy27 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 4 snoopy27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm using Java script to interpret a text that was entered in the previous page.

Reply With Quote
  #6  
Old March 19th, 2003, 07:41 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 20 m 5 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
then use the onLoad even in the body tag to call a javascript function that would set the radio button or your choice checked.

Reply With Quote
  #7  
Old March 19th, 2003, 11:07 AM
snoopy27 snoopy27 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 4 snoopy27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Got it to work! Thanks so much!

Reply With Quote
  #8  
Old March 23rd, 2003, 12:50 PM
dotcomguy dotcomguy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: #devshed @ irc2.beyondirc.net
Posts: 231 dotcomguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 40 sec
Reputation Power: 6
Send a message via ICQ to dotcomguy Send a message via AIM to dotcomguy Send a message via Yahoo to dotcomguy
Quote:
Originally posted by M.Hirsch
<INPUT TYPE="RADIO" NAME="room" VALUE="Red" CHECKED>Red


or . . .

<input type="radio" name="room" value="red" checked="checked" />

__________________
.

Reply With Quote
  #9  
Old March 23rd, 2003, 01:00 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
Yes, but AFAIK this is XHTML syntax and thus not downward compatible.

Reply With Quote
  #10  
Old March 23rd, 2003, 09:10 PM
dotcomguy dotcomguy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: #devshed @ irc2.beyondirc.net
Posts: 231 dotcomguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 40 sec
Reputation Power: 6
Send a message via ICQ to dotcomguy Send a message via AIM to dotcomguy Send a message via Yahoo to dotcomguy
Quote:
Originally posted by M.Hirsch
Yes, but AFAIK this is XHTML syntax and thus not downward compatible.

Yes, that is XHTML, which I had thought to be backwards compatible with HTML.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Radio Buttons Default value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway