/    Sign up×
Community /Pin to ProfileBookmark

Textbox Visibility Issue

Hello Gang!

I have a bit of a troublesome spot. I am working on a web page for an instructional course. The user reads a scenario, and then in a text field types their response. What I want to have is a button which says “Check” below the text field which will THEN show a textfield which already has a paragraph of the appropriate answer in it. I have code I found on another reference site, but it does the reverse… the text box is visible right away and you click on a text link to make the box be hidden. Can someone please help modify my code so the textarea is hidden initially and shows when the user clicks the check button?

[CODE]
<script type=”text/javascript”>

function hide(status) {

if (status == “hidden”) {
document.getElementById(“textbox”).style.visibility = “hidden”;
document.getElementById(“button”).innerHTML = “<a onclick=”hide(‘show’)” href=”#”>Show Textbox</a>”;
}
else {
document.getElementById(“textbox”).style.visibility = “visible”;
document.getElementById(“button”).innerHTML = “<a onclick=”hide(‘hidden’)” href=”#”>Hide Textbox</a>”;
}

}

</script>
[/CODE]

[code=html]
<span id=”button”>
<a onclick=”hide(‘hidden’)” href=”#”>Hide Textbox</a>
</span>
<textarea cols=”32″ rows=”8″ id=”textbox” name=”Answer” >Use the internal reporting chain of command. You should immediately bring this to the attention fo your supervisor. If the situation does not seem to be addressed, you should report it to the next higher level supervisor, contact your CBI Officer, or call the CBI helpLIne.</textarea>
[/code]

Any help is greatly appreciated!

Thanks!
~metallifan15

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SynergySage89Jan 13.2009 — For starters, you should load the answer field, as a hidden field when the document loads:

function hideAnswer(){
document.getElementById("textbox").style.visibility="hidden";
}


Then its a process of logic from there.
×

Success!

Help @metallifan15 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...