Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2003, 08:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Checkboxes

Hi there.

I have a form that I am posting but in the form itself, I have a checkbox. What I want to happen is that if that checkbox is checked by the user, then another text field appears for them to fill in. I'm not sure how to do this. Here is my code at present (which incidentally doesn't work!)

input name="PI" type="checkbox" id="PI" value="Add" >

             <%strAdd = request("PI")

        if strAdd = "Add" then%>

               <input name="PIU" type="text" class="TextBox" id="PIU">

        <%else%>

<%end if%>

thanks in advance

Adam
 
Old August 28th, 2003, 01:04 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'll ask an obvious question: Are you posting the form by some means after you click the checkbox? Or are you expecting the textbox to appear instantly when you tick the checkbox?
 
Old August 29th, 2003, 03:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Sorry, yes I wasn't making it totally clear.

I need the textbox to appear instantly if the checkbox is ticked.

Regards

Adam
 
Old August 29th, 2003, 06:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You just need abit of client-side javascript (change the bit in red to the name of your form):
Code:
function toggleTextBox(bChecked, oTextBox)
{
  if (bChecked)
    oTextBox.style.display = "block";
  else
    oTextBox.style.display = "none";
}
...
<INPUT type="checkbox" id="PI" name="PI" onclick="toggleTextBox(this.checked, document.frmCheck.PIU);">
<INPUT type="text" name="PIU" id="PIU" value="" style="display:none;">
...
 
Old August 29th, 2003, 07:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Fantastic!

Thanks very much!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview with checkboxes kgaughan1 ASP.NET 2.0 Professional 0 February 11th, 2007 11:31 PM
Listboxes and Checkboxes vanguardmike Classic ASP Basics 2 January 2nd, 2007 05:28 PM
Using Checkboxes in datagrid ractim General .NET 2 September 21st, 2004 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.