473,654 Members | 3,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

showing a textbox if criteria is met

i have a set od radio buttons what i wanty to do is when one particular
button is selected bring up an additional text box for additional
information

how would i do this

Jul 23 '05 #1
5 1508


chris wrote:
i have a set od radio buttons what i wanty to do is when one particular
button is selected bring up an additional text box for additional
information


You should hide the input with script and not with static HTML/CSS as
otherwise the page is not functional if script is not enabled or supported:

<html lang="en">
<head>
<title>toggli ng the CSS display property</title>
<script type="text/javascript">
function hideElement (element) {
if (element.style) {
element.style.d isplay = 'none';
}
}
function showElement (element) {
if (element.style) {
element.style.d isplay = '';
}
}
</script>
</head>
<body>
<form name="formName" action="whateve r.php">
<input type="radio" name="radioName "
onclick="if (this.checked) {
showElement(thi s.form.elements .inputName);
}"
value="Kibology ">
<input type="radio" name="radioName "
onclick="if (this.checked) {
hideElement(thi s.form.elements .inputName);
}"
value="JavaScri pt">
<input type="text" name="inputName ">
</form>
<script type="text/javascript">
hideElement(doc ument.forms.for mName.elements. inputName);
</script>
</body>
</html>

That should make the page functional in any browser and allow the
desired effect in IE4+, Netscape 6/7, Mozilla, Opera 7 and other
browsers allowing to change the CSS display setting dynamically.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
chris wrote:
i have a set od radio buttons what i wanty to do is when one particular
button is selected bring up an additional text box for additional
information

how would i do this


<html>
<head>
<script>
function ShowTextBox(){

Text_b_1 = document.getEle mentById("TextB oxOne");
Text_b_1.style. display="block"

}
</script>
</head>
<body>

<form name="form1">
<input type="button" onClick="ShowTe xtBox()">
<input type="text" name="textbox1" value="" id="TextBox1"
style="display: none">
</form>
</body>
</html>
Modify as you need. Just call the ShowTextBox to make the textbox (with
name textbox1 and id TextBox1) appear.

Make Text_b_1.style. display="none" to make it disappear again.
Jul 23 '05 #3
On Sat, 21 Aug 2004 23:25:47 +1200, Will Gittoes <As********@NoS pam.org>
wrote:

[snip]
<script>
Valid HTML requires the type attribute.

<script type="text/javascript">
function ShowTextBox(){

Text_b_1 = document.getEle mentById("TextB oxOne");
You should declare that variable using the var keyword to prevent it from
becoming global. It's also preferable to access form controls through the
containing form (if it exists) as that is likely to work across more
browsers.

var elem = document.forms['formName'].elements['controlName'];
Text_b_1.style. display="block"
The style element should be tested before it's used to prevent unnecessary
errors. Furthermore, INPUT is an inline-, not block-level, element.

if(elem.style) {
elem.style.disp lay = 'inline';
}

However, as the control should be visible by default (see below), simply
assigning an empty string ('') will be sufficient.

[snip]
<input type="text" name="textbox1" value="" id="TextBox1"
style="display: none">


As Martin said in his post, that is a bad idea. If scripting is not
available, or the browser doesn't support the manipulation of inline
styles, the page becomes unusable. The textbox should only be hidden by a
script, as only a script can show it again.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

Pretty simple, I've just done a similar thing.

Put your text box where you want it to appear, then give i
style="visibili ty: hidden;". Give it a name, too, say "theBox".

Now create an onclick function for your radio button that changes th
text box to visible. Here's an example of a function that I created:

function makeVisibile(th eThing) {
if (navigator.user Agent.match('MS IE')) {
theThing.style. setAttribute('v isibility','vis ible');
} else {
theThing.style. visibility = 'visible';
}
return false;
}

Where theThing is a reference to your text box. Here's how to cal
it:

onclick="makeVi sibile(this.for m.theBox);"

Of course you will want to create a "makeInvisi ble" function for th
other radio buttons so when they are clicked, theBox disappears.

Cheers
-
Rob

Jul 23 '05 #5
On Sat, 21 Aug 2004 08:32:42 -0500, RobG
<Ro*********@ma il.forum4design ers.com> wrote:
Pretty simple, I've just done a similar thing.

Put your text box where you want it to appear, then give it
style="visibili ty: hidden;".
No, don't. Read my response to Will who made a similar suggestion.

[snip]
function makeVisibile(th eThing) {
if (navigator.user Agent.match('MS IE')) {
Avoid browser detection. Use feature detection instead.

<URL:http://jibbering.com/faq/#FAQ4_26>
theThing.style. setAttribute('v isibility','vis ible');
That doesn't do anything different than the other execution path.
} else {
theThing.style. visibility = 'visible';
You should check that the style object exists before using it. Again: use
feature detection.
}
return false;


That is superfluous. It has no effect.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3032
by: Henry | last post by:
I was trying to work through the Lab 2 exercises in the Microsoft's Windows-Based Applications in Visual C#. While I am not showing any errors I am also not seeing the mainMenu object when I run the application. I am wondering if someone could point out why in the code below: using System; using System.Drawing; using System.Collections;
3
4796
by: Rebekkah | last post by:
I did a search but couldn't find a question similar to mine. I need to count the values in a textbox on a report and have the count subtotal in a group footer. But I need three different counts on the same textbox because there are three possible values and I need a count on each. I can't just do a simple DCount on the table and manually define the criteria because there are many different groups that will need the counts for only that group....
5
2769
parshupooja
by: parshupooja | last post by:
Hello I am trying to create to a Timesheet . I am intiating number of textboxes and label based on criteria chosen by admin. This is what i have written in pageload to generate timesheet for 2 weeks for (int i = 1; i <= 14; i++) { Label date = new Label(); date.ID = "Item" + i.ToString(); date.Text = DateTime.Now.AddDays(i).ToShortDateString(); Label day = new Label(); ...
1
1723
by: andy143vivi | last post by:
hi, just wondering how can i get a value from a text box on a different form to apply in a query, can i do this in query criteria? or i have to make a vb code in command click? i have a form with a textbox, and a command click, what i want, once click it will open a query form base on the value of the textbox, it would be easy if i could use the query criteria part but seems like i cant do that, so i might need a vb code advise if ever i wont...
1
1619
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime = (TextBox)EditEventForm.Rows.Cells.Controls; TextBox EndTime = (TextBox)EditEventForm.Rows.Cells.Controls;
4
18332
by: billa856 | last post by:
Hi, My Project is in MS Access 2002. In that I have one form which I am using for data entry. Now in that I have some TextBoxes like PalletNo,TotalPallets,ItemNo,LONo,PONo,BatchNo,LotNo,Cartons,PcsPerCarton etc. Now when person scan a barcode from paper it will automatically enter Number(Like 24914) in first PalletNo TextBox. In the AfterUpdate event of PalletNo TextBox I put some code so it will search the values of...
5
5050
by: RHooper | last post by:
Hi, I'm new to Access, so I apologize if this question is trivial. I am trying to set-up a quick filter for users to define on a form bound to a table. I have a combo box called cboSearchCriteria from which users can select the field they wish to filter by and a text box called txtSearch into which they can specify criteria. The user then clicks a button to filter: Private Sub cmdFilter_Click() Dim strWhere As String ...
9
3239
daoxx
by: daoxx | last post by:
Hi Question#1 Is it possible to show a textbox (linked to a field) when the mouse pointer goes over a checkbox, and hiding it when the pointer goes away, and at the same time allowing the user to handle it like a regular textbox? If so, how? Question#2 What is the best way of showing data that is linked to other data? Example: Paul's ID is 1. If I select Paul in a combo box, how can I make a textbox get Paul's ID from the table...
1
1501
parshupooja
by: parshupooja | last post by:
Hey All, I am working on vb.Net 2.0 Desktop application. Can any one suggest me how to do Autocomplete TextBox? I have 1 dropdown and one textbox dropdown has criteria such as Last Name, First Name, id etc. When user selects say criteria Last Name and starts typing in Textbox, I want autocomplete on Textbox. Thanks!
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.