473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Textbox appearing after radio button is selected--new code

19
I changed my code...Now everytime i click a radio button, a text box appears...What i want is when i hit a particular radio button, the textbox should only appear next to that radio button. And if another radio button is selected, then the 1st textbox should disappear and should display in front of the new radio button selected.

Following is my code:

<html>

<head>

<script type="text/javascript">

function Markit(name) {

if (name == 'a')
{

var txtInput = document.createElement("INPUT");
txtInput.type="text";
txtInput.id="txtInput"
txtInput.value=" ";
txtInput.size="30"
DivAppend.appendChild(txtInput);


}

if (name == 'b'){
var txtInput = document.createElement("INPUT");
txtInput.type="text";
txtInput.id="txtInput"
txtInput.value=" ";
txtInput.size="30"
DivAppend.appendChild(txtInput);


}
}
</script>

</head>

<bodyonLoad="appendObj();">
<div id="DivAppend">
</div>



<br />

<input onclick="Markit('a')" type="radio" name="a" value="y">Male
<br />

<input onclick="Markit('b')" type="radio" name="a" value="n">Female
<br />
</body>
</html>


Thanks
Jan 9 '07 #1
2 10062
AricC
1,892 Expert 1GB
Have you thought about putting the radio buttons and text boxes in a 2 column table?
Jan 9 '07 #2
acoder
16,027 Expert Mod 8TB
This is a Javascript problem. Are you sure you want to create a new text box every time a radio button is clicked or do you want to move the text box from one radio button to the other?

If you want to move then you should move the div instead of creating a new object every time. If you want to delete the old object, you need to remove it from the div. At the moment, your code adds text boxes with the same name to the div each time a radio button is clicked and the div appears before the radio buttons.

Why not define two divs, one after each radio button? When a radio button is clicked, the div corresponding to the radio button shows its text box and hides the other one using
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(object).style.visibility = 'visible'
and
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(id).style.visibility = 'hidden'
respectively.
Jan 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context...
2
by: Bart Verbeke | last post by:
Hi, I have a form with 2 radio buttons (ACCEPT/REJECT). When the page is initially loaded, no textbox should be visible. When a user clicks the REJECT radio button, a textbox should...
2
by: teddy.am | last post by:
Guys, I have a set of 6 radio buttons, infront of each one there's a textbox .... i need all textboxes disabled .... once one of the radio buttons is selected, the texbox infront of it will be...
0
by: ana_gil | last post by:
Hello I need help whit a validation control. I have a radio button list which i made required: <asp:radiobuttonlist id="_AlergiasSN" runat="server"> <asp:listitem id="_AlergiasS"...
1
by: jw01 | last post by:
Im trying to write a java script in HTML in which when a particular radio button is selected, a textbox would appear write next to the selected item. e.g (RADIO BUTTON) fhd: (RADIO BUTTON) fdj:...
2
by: Peted | last post by:
I have 6 radio buttons in a column with a single line text box next to each rb. is there a general straightforward way to link a radio button to the textbox next to it. I want to be able to...
5
by: Kulgan | last post by:
Hi all, Is it possible in javascript to add a textbox when the last of three radiobuttons is clicked ? thanks !
0
by: Gary W. Smith | last post by:
Hello, I have a simple form with a radio button group on it and I need to do some basic validation based upon which button is checked. Here is a little more detail. if button one is...
4
by: januincse | last post by:
There 2 radio buttons.when a radio is clicked textbox should appear,when another radio clicked the existing textbox should disappear and new textbox should be enabled.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.