Pyro-San
asked on
Ratio Field + Text Field Hide
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)
How do i do this using prefrably javascript/clientside (and no .NET)
Do you have any existing code....easier if we know what it is?
ASKER
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("i d")%>">
</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))
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")%
<input type="radio" name="calltype<%=rs("id")%
<input type="radio" name="calltype<%=rs("id")%
</td>
<td>
<input type="text" name="stringNumber<%=rs("i
</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))
That puts 3 radio buttons for every 1 textbox?
ASKER
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.
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")%
Only visible if 2 is selected? What about 1 and 3...what is to happen?
ASKER
the text box is hidden
This should work: (but put your ASP back in)
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ShowHide(val) {
if(val==2){
document.form1.stringNumbe r.style.vi sibility = "visible";
}
else
{
document.form1.stringNumbe r.style.vi sibility = "hidden";
document.form1.stringNumbe r.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>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ShowHide(val) {
if(val==2){
document.form1.stringNumbe
}
else
{
document.form1.stringNumbe
document.form1.stringNumbe
}
}
//-->
</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>
ASKER
is there a way to do it without having lots of "document.form1.stringNumb er.style.v isibility = "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.stringNumbe rvalue2.st yle.visibi lity = "hidden";
or is it going to be to dificult to do it like that?
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.stringNumbe
or is it going to be to dificult to do it like that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did that solve it?
ASKER
yeah it did, thanks :D