Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pop up text area after click yes from drop down list

2 views
Skip to first unread message

weiwei

unread,
Jan 6, 2004, 5:28:52 PM1/6/04
to
Hi all
I want to write a asp script, basically, that has drop down box in the
form, if user select Yes,
on the same page, a hidden textarea will show up, if user select No,
then nothing happen.
so far, my code is unsuccessful, in addition, I also got syntax error
on the response.write line
anyone has idea, please help me out, I would really appreciate your
help

below is my current code


<form name="form1" method="post" action="test13.asp">

<select name="test">
<option value=""></option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>

<%strtest = request("test")%>
<%
If strtest = "Yes" Then
response.write "<textarea name="whatis" cols="50"></textarea>"
Else

End if
%>

</form>

Roland Hall

unread,
Jan 6, 2004, 6:33:06 PM1/6/04
to
"weiwei" wrote:
: Hi all

: I want to write a asp script, basically, that has drop down box in the
: form, if user select Yes,
: on the same page, a hidden textarea will show up, if user select No,
: then nothing happen.

Can't do that. ASP server script has already processed and user input is
now working with client script.

: so far, my code is unsuccessful, in addition, I also got syntax error


: on the response.write line
: anyone has idea, please help me out, I would really appreciate your
: help

Correct. You're trying to reference elements that do not exist. The ASP
processor only processes ASP code, not client-side script or HTML. It just
passes those to the client. The browser is then required to process the
code.

: below is my current code


:
: <form name="form1" method="post" action="test13.asp">
:
: <select name="test">
: <option value=""></option>
: <option value="Yes">Yes</option>
: <option value="No">No</option>
: </select>
:
: <%strtest = request("test")%>

request is actually Request.QueryString and it is looking for ?test=szValue

: <%


: If strtest = "Yes" Then
: response.write "<textarea name="whatis" cols="50"></textarea>"
: Else

no else clause included to else not required

: End if
: %>
: </form>

To make this work, consider the following:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<script type="text/javascript">
function getState(x) {
if(x == 1) {
document.getElementById("ta1").style.display='block';
} else {
document.getElementById("ta1").style.display='none';
}
}
</script>
</HEAD>
<BODY>
<form name="form1">
<select id="test" name="test" onchange="getState(this.selectedIndex)">


<option value=""></option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>

</form>
<textarea id=ta1 rows=5 cols=40 style="display: none; overflow: auto">some
text for filler</textarea>
</BODY>
</HTML>

http://kiddanger.com/lab/displayta.asp

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0
-Technet Script Center-
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp


Don Grover

unread,
Jan 6, 2004, 10:52:02 PM1/6/04
to
Thats usefull Roland
But how would you do it with a checkbox as it does not have a selected
index.

Many Regards
Don


"Roland Hall" <nobody@nowhere> wrote in message
news:%235mZHiK...@TK2MSFTNGP09.phx.gbl...

Roland Hall

unread,
Jan 7, 2004, 2:23:20 AM1/7/04
to
"Don Grover" wrote:
: Thats usefull Roland

: But how would you do it with a checkbox as it does not have a selected
: index.

This really isn't a true comparison because I would not use a checkbox as a
toggle unless it was just one.
http://kiddanger.com/lab/displayta1.asp

However, you could do it with two checkboxes.
http://kiddanger.com/lab/displayta2.asp

But, that is not really a true comparison to the collection routine I wrote
for the select. A better comparison would be one that I wrote in VBScript
to be run with WSH. I have converted it to JScript for this exercise.

This is the VBScript version converted from WSH.
http://kiddanger.com/lab/exp.asp

This is the JScript version.
http://kiddanger.com/lab/expjs.asp

HTH...

Don Grover

unread,
Jan 7, 2004, 2:07:22 AM1/7/04
to
This is exactly what I need , can you post the source for this.
Wome of my client forms are getting overly long with all the comment data
they have to put in.

Thanks, where would we be without you guys who give their time to us less
experienced.
Many Thanks
Don

Roland Hall

unread,
Jan 7, 2004, 4:36:34 AM1/7/04
to
"Don Grover" wrote:
: This is exactly what I need , can you post the source for this.

: Wome of my client forms are getting overly long with all the comment data
: they have to put in.

Hi Don...
The files are .asp extension but there is not any server-side code in them.
It's all done on the client side. You can just view source to get the code.

I take that back. exp.asp and expjs.asp both call a file to process the
form: exp2.asp. I doubt you need this but this is the code for it. It was
originally written to process the form from the .vbs file.

<%@ Language=VBScript %>
<% Option Explicit
' called from c:\exp.vbs
dim oArgs, i
oArgs = split(Request.QueryString("tasks"),", ")
for i = 0 to ubound(oArgs)
Response.Write(oArgs(i) & "<br />" & vbCrLf)
next
%>

: Thanks, where would we be without you guys who give their time to us less
experienced.

Thank you. I'm sure everyone here learns from someone, at times, especially
when code can be written many different ways to get the same result. It
also helps me to try to help someone else and that is a learning experience
because I don't always know how something is done but rather that I want to
try to offer a solution. This requires research and I gain knowledge so I
also get a benefit, not to mention it is a way to give to your profession.
Now if I could just find a job... (O:=

Roland


Brynn

unread,
Jan 7, 2004, 1:04:18 PM1/7/04
to

First of all ... in case your new ... the people that read this .db
group most all read the .general group as well. There is no reason to
multipost your question.

I have answered your question in the .general group ... it sounds like
a client-side Javascript solution you are looking for ... I have
created a sample page of what I think you are trying to do ... look at
the code with View Source.

http://www.coolpier.com/cp/_dev/textareaOnSelect.asp

let me know if this is what you were looking for :)

Brynn
www.coolpier.com

0 new messages