Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide data 1

Status
Not open for further replies.

MaddogC

Programmer
Dec 4, 2003
134
GB
I have an ASP 3.0 page, which is a questionnaire. The user fills in the
fields, hit's submit, then the values are written to a database.

However, the form should hide certain questions unless the user changes
a drop down box from No to Yes, in which case the further questions should appear on the screen.

Is there a simple way to unhide the extra fields without refreshing the screen?

If I refresh the screen the user's input that has already been entered is reset which is obviously no good!!

I don't want to use session variables as there are 70 odd fields in the table.
 
MaddogC,
This control is efective on client-side via JavaScript, for example.
You need create a <div name=&quot;something&quot; style='display:none'></div>, This keep the object hidden then your user to changes the drop down, in this case call the function on Java script that change the style of the div refered to style.display='block' and it is appear in your screen.
I hope had help You

Sorry for my english,I am a Brasilian and my english is very poor...
 
These sample code may help you get started:

First, create an HTML file and put this code inside your head tag:
Code:
<style type=&quot;text/css&quot;>
  .hideable
  {
    position: relative;
    visibility: hidden;
  }
</style>
<script language=&quot;JavaScript&quot;>
  function shownextfield()
  {
    if (document.frm.C1.checked)
    {
      document.getElementById(&quot;area1&quot;).style.visibility = &quot;visible&quot;;
      document.frm.txtbox.focus();
    }
    else
    {
      document.getElementById(&quot;area1&quot;).style.visibility = &quot;hidden&quot;;
      document.frm.txtbox.value = &quot;&quot;;
    }
  }
</script>

Then, put this in your body tag:
Code:
<form name='frm' method=post action=&quot;Nextpage.asp&quot;>
  <input type=&quot;checkbox&quot; name=&quot;C1&quot; value=&quot;ON&quot; onclick=&quot;shownextfield()&quot;>
  Check here to show the text field
  <br>
  <div class='hideable' id='area1'>
      This is a text field:<br>
      <input id='txtbox' name='txtbox' type='text'>
      <input type='submit'>
  </div>
</form>
 
Works a treat thanks!

One question re DIV tags however, can these be used to surround a table? or <TR>
 
The DIV tags is used this way:
<div name=&quot;rrr&quot; id=&quot;iii&quot; style.display=&quot;none&quot;>
<table>
</table>
</div>

I hope help you a litle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top