![]() |
| |||||||
| Sponsored Links |
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Hi, I have a group of checkboxes when the user clicks on the Other checkbox i want to show a textbox Here is my code but it doesnt work the page is refreshed when the checkbox is clicked i see the textbox and it disappears Code:
<%
displayopt = "none"
%>
function showtextbox()
{
if(document.frm1.c2j.checked == true)
{
alert("checkedc");
hideAll2();
changeDiv('display', 'block');
}
else
{
alert("unchecked");
hideAll2();
}
}
function changeDiv(the_div,the_change)
{
var the_style = getStyleObject(the_div);
if (the_style != false)
{
the_style.display = the_change;
}
}
function hideAll2()
{
changeDiv("display", "none");
}
function getStyleObject(objectId)
{
if (document.getElementById && document.getElementById(objectId))
{
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId))
{
return document.all(objectId).style;
}
else
{
return false;
}
}
<input type="checkbox" name="c2a" id="c2a" name="Reserves"> Reserves
<input type="checkbox" name="c2b" id="c2b" name="Army"> Army
<input type="checkbox" name="c2c" id="c2c" name="Navy"> Navy
<input type="checkbox" name="c2d" id="c2d" name="Air Force"> Air Force
<input type="checkbox" name="c2e" id="c2e" name="Trainee"> Trainee
<input type="checkbox" name="c2f" id="c2f" name="Cops"> Cops
<input type="checkbox" name="c2g" id="c2g" value="Other"
<% if Request.form("c2g")= "Other" then
Response.Write "checked=""true"""
Else
Response.Write ""
end if
%>
onClick="this.form.action = '<%=Request.ServerVariables("Script_Name")%>'; this.form.submit(); showtextbox();">Other
<div id="display" style="display: <%=displayopt%>;">
<input type="textbox" name="othertext" id="othertext" size="35" value=""/>
</div>
|
| Sponsored Links |
|
#2
| ||||
| ||||
| I wouldn't even bother submitting the form when you click it. Just call a JavaScript function to change the visibility on the onclick event.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#3
| ||||
| ||||
| I agree with JMH. Seems a very roundabout way to get something so simple done. Try this:- Code:
<input type="checkbox" name="c2a" id="c2a" name="Reserves"> Reserves
<input type="checkbox" name="c2b" id="c2b" name="Army"> Army
<input type="checkbox" name="c2c" id="c2c" name="Navy"> Navy
<input type="checkbox" name="c2d" id="c2d" name="Air Force"> Air Force
<input type="checkbox" name="c2e" id="c2e" name="Trainee"> Trainee
<input type="checkbox" name="c2f" id="c2f" name="Cops"> Cops
<input type="checkbox" name="c2g" id="c2g" value="Other" onClick="if(this.checked){document.getElementById('othertext').style.visibility='visible'}else{document.getElementById('othertext').style.visibility='hidden'}">Other
<input type="textbox" name="othertext" style="visibility:hidden;" id="othertext" size="35" value=""/>
|
| The Following User Says Thank You to richyrich For This Useful Post: | ||
mehere (May 30th, 2008) | ||
|
#4
| |||
| |||
| richyrich, the reason why i have a page submit is because depending on what value they selected for the checkbox i display a different section of questions thats why so if its other i display a total different section of questions and also get the value of other so i need the page to be submitted and a textbox to be displayed when the other checkbox is clicked todd |
|
#5
| ||||
| ||||
| If you're going to submit the page, why bother using Javascript to display the textbox? Just have:- Code: if request.form("c2g") = "Other" then
response.write("<input type=""textbox"" name=""othertext"" id=""othertext"" size=""35"" value="""" />")
end if
|
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| display textboxes problem | todd2006 | JavaScript Programming | 13 | May 22nd, 2008 02:54 PM |
| display problem | todd2006 | JavaScript Programming | 19 | May 12th, 2008 02:08 PM |
| text display problem | todd2006 | HTML & CSS Help | 10 | May 7th, 2008 08:14 PM |
| display problem with drop downs | todd2006 | JavaScript Programming | 3 | May 5th, 2008 05:31 PM |
| IE and Mozilla display problem | todd2006 | HTML & CSS Help | 11 | April 18th, 2008 01:17 PM |