Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

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 Codewalkers Forums Sponsor:
  #1  
Old January 14th, 2004, 07:33 AM
DorkRawk DorkRawk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 173 DorkRawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to DorkRawk
Javascript radio button

I am trying to implement a feature on the registration of my site so that users have a Yes/No radio button to check if they have a band and if they select yes, then a text box to enter the band name will show up but I dont know how to print the HTML useing JavaScript so that it will just go undeneath the Yes/No radio buttons and I've had no luck finding this seemingly basic function through Googleing. Heres my code....
Code:
<script language="JavaScript">
	<!-- hide
	function bandName()
	{
SOME HOW PRINT "<INPUT TYPE='TEXT' NAME='reg[bandname]' VALUE='' SIZE=30 MAXLENGTH=150>"!!!!!!
	}
	// end the hiding comment -->
	</script>

then some HTML tables and stuff...
Code:
<INPUT TYPE="radio" NAME="reg[haveband]" VALUE="0" checked> no
			<INPUT TYPE="radio" NAME="reg[haveband]" VALUE="1" onClick="bandName();"> yes<br>


If somebody knows a better way to do this w/ PHP that would be great too! Thanks.

Reply With Quote
  #2  
Old January 14th, 2004, 09:31 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Javascript radio button

DorkRawk,

Let me make a two suggestions here.

1. Rather than displaying a textfield when the user hits 'yes' option, you can just provide the textfield to enter bandname without option buttons. Then if you has entered something on the textfield that mean the answer for your question 'Have Band?' is yes. You can let them know by saying 'Leave blank if you have no band'...

2. You could send user to another page to enter the band name if you selected the answer 'yes' in option buttons. I do not accept using JavaScript much in validation though it is faster than other methods because some visitors of yours browser's JS can be disabled.

I hope I was clear.

Reply With Quote
  #3  
Old January 14th, 2004, 09:33 AM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 4
RE: Javascript radio button

Whenever you are hiding or emerging elements, you want to incorporate some kind of <div> tag along with your javascript so it has something to reference as a start and finish. Try this on for size:
Your javascript:

Code:
<script type="text/javascript">
 function showlayer(el) 
 {document.getElementById(el).style.visibility = 'visible'}

 function hide(el)
 {document.getElementById(el).style.visibility = 'hidden' }
</script>


Your html:

Code:
<input type=radio name="reg['bandname']" value="no" checked onClick='hide("divName")'>No<br />
<input type="radio" name="reg['bandname']" value="yes" onClick='showlayer("divName")'>Yes<br />
<div style="visibility:hidden" id="divName">
   <input name="text" name="reg[bandname]" value="" size="30" maxlength="150">
</div>


Enjoy!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Javascript radio button


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 5 hosted by Hostway
Stay green...Green IT