Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 01-19-2007, 09:52 PM   #1 (permalink)
Inactive
 
ladan's Avatar
 
Join Date: 07-21-04
Posts: 96
iTrader: 0 / 0%
ladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really nice
Send a message via Yahoo to ladan Send a message via Skype™ to ladan
Question How to create this Javascript form?

I want to create a form on my website that has 3 radio buttons and when someone clicks on each radio button, a different text paragraph appears.

I tried to find such a script by searching in Google but they all were just ordinary web forms.

So do you know how I can do this using Javascript?

Thanks,
ladan is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-19-2007, 10:03 PM   #2 (permalink)
Contributing Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
http://www.v7n.com/forums/coding-for...l-i-swear.html
Just change it so that the radio set uses that on change, or maybe the form itself does. I'm not great at JS but that should get you somewhere with it.
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-19-2007, 11:19 PM   #3 (permalink)
Inactive
 
ladan's Avatar
 
Join Date: 07-21-04
Posts: 96
iTrader: 0 / 0%
ladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really nice
Send a message via Yahoo to ladan Send a message via Skype™ to ladan
Thank you, but it's quite different from what I need. I know the code must have something to do with <div> tag.

Any ideas how to create a form that hides and shows a <div> tag on choosing different options?
ladan is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-21-2007, 07:35 AM   #4 (permalink)
Inactive
 
Join Date: 12-07-06
Location: Nelson
Posts: 62
iTrader: 0 / 0%
Latest Blog:
None

Gannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the rough
Post Show Hide Div's with Radio Buttons

Laden, I hope this helps you...

Put this javascript into the head of your html
Code:
<script type="text/javascript"> function ShowDiv(divName) { HideDivs(); if (document.all) { document.all.text1.style.visibility = "visible"; } else { document.getElementById(divName).style.visibility = "visible"; } } function HideDivs() { if (document.all) { document.all.text1.style.visibility = "hidden"; document.all.text2.style.visibility = "hidden"; document.all.text3.style.visibility = "hidden"; } else { document.getElementById('text1').style.visibility = "hidden"; document.getElementById('text2').style.visibility = "hidden"; document.getElementById('text3').style.visibility = "hidden"; } } </script>
The rest you put into the body of the html

Code:
<form name="form1" method="post" action=""> <input type="radio" onChange="ShowDiv('text1')" name="radiobutton" value="radiobutton" checked> text 1 <input type="radio" onChange="ShowDiv('text2')" name="radiobutton" value="radiobutton"> text 2 <input type="radio" onChange="ShowDiv('text3')" name="radiobutton" value="radiobutton"> text 3 </form> <br /> <div id="text containter" style='width:420; height:85px; background:silver; position: absolute; '> <div id='text1' style="position:absolute; left:5px; top:10px"> <font color='#0000FF'>I want to create a form on my website that has 3 radio buttons </font> </div> <div id='text2' style='position:absolute; left:5px; top:10px; visibility:hidden;'> <font color='#0000FF'>and when someone clicks on each radio button, a different text paragraph appears.</font> </div> <div id='text3' style='position:absolute; left:5px; top:10px; visibility:hidden;'> <font color='#0000FF'>So do you know how I can do this using Javascript?</font> </div> </div>
I hope you know a little about programming. With this you can easily customize it.

I have put up a demo page with this in action at
http://haidavision.no-ip.info/gannya...s/showhide.htm
Gannyaa is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-22-2007, 11:31 PM   #5 (permalink)
Inactive
 
ladan's Avatar
 
Join Date: 07-21-04
Posts: 96
iTrader: 0 / 0%
ladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really niceladan is just really nice
Send a message via Yahoo to ladan Send a message via Skype™ to ladan
Thank you very much Todd! I'll try it on my website.
ladan is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-23-2007, 06:57 PM   #6 (permalink)
Inactive
 
Join Date: 12-07-06
Location: Nelson
Posts: 62
iTrader: 0 / 0%
Latest Blog:
None

Gannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the roughGannyaa is a jewel in the rough
Er. Again I noticed that my code didn't work properly with IE5.
So I retested and reposted. The difference is instead of onChange=
I now use onClick=
This solves the IE5 problem and still works with every other w3dom browser.
I made the changes to the page with the answer.

http://haidavision.no-ip.info/gannya...s/showhide.htm

Later
Gannyaa is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-12-2009, 02:36 AM   #7 (permalink)
Contributing Member
 
Join Date: 05-10-09
Location: Blackpool
Posts: 113
iTrader: 0 / 0%
Blackpool is liked by many
Todds code is spot on, I used this javascript form code and it works wonders.
__________________
Stay in Blackpool today and view Blackpool Hotels or there always UK's famous hotel group Britannia Hotels.
Blackpool is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax / Javascript Form Help adammc Coding Forum 3 06-01-2007 10:32 PM
how do i create a javascript code that allows me to add links kf9211 Coding Forum 18 01-26-2007 04:16 PM
Javascript Form Validation Help ATLien Coding Forum 9 03-13-2006 12:36 PM
Javascript: form text to bold onclick DragonEye Coding Forum 2 10-17-2004 07:31 AM


Sponsor Links
Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 08:35 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.