Solved

Ratio Field + Text Field Hide

Posted on 2004-03-23
11
315 Views
Last Modified: 2008-03-06
I have a list of fields from a database, I output them to a page with 3 ratio boxes next to them and a text box next to each row, on load the text box is hidden, but when a spesific ratio box is checked the text box is shown and the user is able to type into it, if a different ratio box is selected then the text box hides again.
How do i do this using prefrably javascript/clientside (and no .NET)
0
Comment
Question by:Pyro-San
  • 6
  • 5
11 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 10663379
Do you have any existing code....easier if we know what it is?
0
 

Author Comment

by:Pyro-San
ID: 10663444
no code that is usefull

here is an example of the loop for the output tho

<%
while not rs.eof
%>
<tr>
 <td><%=rs("name1")></td>
 <td>
  <input type="radio" name="calltype<%=rs("id")%>" value="<%=rs("id")%>:1">
  <input type="radio" name="calltype<%=rs("id")%>" value="<%=rs("id")%>:2">
  <input type="radio" name="calltype<%=rs("id")%>" value="<%=rs("id")%>:3">
 </td>
 <td>
  <input type="text" name="stringNumber<%=rs("id")%>">
 </td>
</tr>
<%
wend
%>

when say the #2 radio button is selected the text box will appear when it is not the text box will be hidden
(yeah sorry I keep on typing ratio when it should be radio (I think))
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10663467
That puts 3 radio buttons for every 1 textbox?
0
 

Author Comment

by:Pyro-San
ID: 10663501
yep.
that is the way it needs to be setup, the user gets a choice 1 out of 3 has to be selected, if the radio button (example as above 2(<input type="radio" name="calltype<%=rs("id")%>" value="<%=rs("id")%>:2">)) is selected then the text box is visible, otherwise it is hidden.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10663544
Only visible if 2 is selected?  What about 1 and 3...what is to happen?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Pyro-San
ID: 10663554
the text box is hidden
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10663614
This should work: (but put your ASP back in)

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function ShowHide(val) {
if(val==2){
document.form1.stringNumber.style.visibility = "visible";
}
else
{
document.form1.stringNumber.style.visibility = "hidden";
document.form1.stringNumber.value = "";
}
}

//-->
</SCRIPT>

<FORM action="" method=POST id=form1 name=form1>
<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
      <TR>
            <TD>
                <input type="radio" name="calltype" value=":1" LANGUAGE=javascript onclick="return ShowHide(1)">
                  <input type="radio" name="calltype" value=":2" LANGUAGE=javascript onclick="return ShowHide(2)">
                  <input type="radio" name="calltype" value=":3" LANGUAGE=javascript onclick="return ShowHide(3)">
            </TD>
            <TD>
               <input type="text" name="stringNumber">
            </TD>
      </TR>
</TABLE>
</FORM>

0
 

Author Comment

by:Pyro-San
ID: 10663679
is there a way to do it without having lots of "document.form1.stringNumber.style.visibility = "hidden";"?
because there is going to be obviously more than one text box on the page, usually MIN 50 of them?
something like ShowHide(1,value2)
document.form1.stringNumbervalue2.style.visibility = "hidden";
or is it going to be to dificult to do it like that?
0
 
LVL 31

Accepted Solution

by:
alorentz earned 125 total points
ID: 10663717
Here's one way to do it:

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function ShowHide(val, target) {
//target will be the rs("id") that you put in the parameters
if(val==2){
eval("document.form1.stringNumber"+target+".style.visibility = 'visible'");

}
else
{
eval("document.form1.stringNumber"+target+".style.visibility = 'hidden'");
eval("document.form1.stringNumber"+target+".value = ''");
}
}

//-->
</SCRIPT>

<FORM action="" method=POST id=form1 name=form1>
<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
      <TR>
            <TD>
                <input type="radio" name="calltype" value=":1" LANGUAGE=javascript onclick="return ShowHide(1, 1)">
                  <input type="radio" name="calltype" value=":2" LANGUAGE=javascript onclick="return ShowHide(2, 1)">
                  <input type="radio" name="calltype" value=":3" LANGUAGE=javascript onclick="return ShowHide(3, 1)">
            </TD>
            <TD>
               <input type="text" name="stringNumber1">
            </TD>
      </TR>
</TABLE>
</FORM>
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10663856
Did that solve it?
0
 

Author Comment

by:Pyro-San
ID: 10663866
yeah it did, thanks :D
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now