Link to home
Start Free TrialLog in
Avatar of sammySeltzer
sammySeltzerFlag for United States of America

asked on

If Yes, then???

Greetings again experts:

I have a dropdown of Yes or No response.

The question, "have you ever received compensation?"

If the user selects No from the dropdown, then s/he goes to the next question.

If the user selects Yes,  a branch off questions follows.

Example, If yes, then where____________
Any ideas how to handle the if yes part of the question?
 
Many thanks in advance

Open in new window

Avatar of CoveyCraig
CoveyCraig

Probably the simplest method to handle a variety pack of potential questions/answers would be to use "Select Case" instead of if/then statements.  You could request the user to identify a type of compensation from a drop-down list; then use something like this:

Select Case Compensation
	Case Stocks
		Response.Write	"Stocks ...."
	Case Cash
		Response.Write	"Cash...."
end Select

Open in new window

Avatar of b0lsc0tt
sammySeltzer,

From what you described I would just use an If statement.  We really need code and details though.  An example is ...

If Request("select1") = "Yes" then
    ' code to test the other questions
Elseif Request("select1") = "No" then

End if

The ElseIf may not be needed but could be used for validation of that field and to "pass" that choice.  It depends on what you are trying to do in this code.  Using either If or Select Case would be the same regarding the "validation" that I mentioned.  Without details it is hard to suggest the best logic and code to use though.

Let me know if you have any questions or need more information.

b0lsc0tt
Avatar of sammySeltzer

ASKER

thanks a lot good people.

I actually currently use radio button with div (to hide or show 2 input boxes based on choice.

For instance, If choice is Yes, then show  4 input boxes.

Otherwise, hide them.

It seems to work but I wanted to do it with <select...> option

here is the code I currently use.

If I can sort of convert everything to dropdown, that would be great.

Thanks again
               <tr>
                <td colspan=2>Have you ever received compensation?</td>
                <td colspan=2>
                <INPUT Type=Radio Name="YesNo" Value="Yes" onClick="document.getElementById('LICROW1').style.visibility = document.getElementById('LICROW2').style.visibility = this.checked ? 'visible' : 'hidden';" >Yes<font size=1></font>&nbsp;
                <INPUT Type=Radio Name="YesNo" Value="No" onClick="document.getElementById('LICROW1').style.visibility = document.getElementById('LICROW2').style.visibility = this.checked ? 'hidden' : 'visible';" >No<font size=1></font>
                </td>
                </tr>
                <tr>
		  <td ID="LICROW1" style="visibility: hidden;"> If so, Private
		   <input type="text" size="35" name="yesPrivate">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Where?
		   <input type="text" size="35" name="yesWhere" class="normaltxt">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Year?
		    <input type="text" size="35" name="yesYear">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Previous comp Participation Year?
		    <input type="text" size="35" name="yesDCYear">
		  </td>
		</tr>

Open in new window

Please clarify the question and whether this is for Javascript (i.e. clientside code that happens with a browser event) or ASP (i.e. server side code that happens after the form is submitted.  You posted this in the ASP zone and asked such a general question I assumed you want ASP and help with server code.  Now it looks like that may not be the case.
After clearing that up please post the relevant code and details.  You mention a select but I don't see one in the html in the snippet.  Since it seems I was really far off before I will hold off on guess at all so please be specific and provide details on what you have and need.  Clarifying exactly what you are asking and need is a good start.
bol
thanks a lot again.

The code I posted is the entire code. It is for the webform.

I can capture the values using server side code.

All I wanted is to be able to select either No or if I select Yes, give me 4 addtional input screens.

BTW: I don't remember saying that I have <select ..option code.

I said I have a radio button code but would love to do this using radio button.

Having said that, if you feel it is easier to with asp, please use asp to help me.

Thanks a lot again
hi Carrzkiss,

Good to "hear" from you again.

This is what I want.

If the user selects No, then that's no additional action required.

If, however, the user selects Yes, then 4 new input textboxes are automally displayed for the user to provide additional information.

Even one input text box and I can add the addtitional 3.

Thanks
this is proving to be a pain trying to implement.
I will continue to see if I can do what you are wanting.
Will let you know.

Carrzkiss
Thanks as always but please don't waste too much of your time on it.

As stated earlier, this code below works.

It's just that I prefer the <select option method

               <tr>
                <td colspan=2>Have you ever received compensation?</td>
                <td colspan=2>
                <INPUT Type=Radio Name="YesNo" Value="Yes" onClick="document.getElementById('LICROW1').style.visibility = document.getElementById('LICROW2').style.visibility = this.checked ? 'visible' : 'hidden';" >Yes<font size=1></font>&nbsp;
                <INPUT Type=Radio Name="YesNo" Value="No" onClick="document.getElementById('LICROW1').style.visibility = document.getElementById('LICROW2').style.visibility = this.checked ? 'hidden' : 'visible';" >No<font size=1></font>
                </td>
                </tr>
                <tr>
		  <td ID="LICROW1" style="visibility: hidden;"> If so, Private
		   <input type="text" size="35" name="yesPrivate">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Where?
		   <input type="text" size="35" name="yesWhere" class="normaltxt">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Year?
		    <input type="text" size="35" name="yesYear">
		  </td>
		  <td ID="LICROW2" style="visibility: hidden;"> Previous comp Participation Year?
		    <input type="text" size="35" name="yesDCYear">
		  </td>
		</tr>

Open in new window

This does not use the <%if Statement%>
But works rather well.
http://ee.cffcs.com/Q_24392862/Q_24392862.asp
code
http://ee.cffcs.com/Q_24392862/Q_24392862.zip

The Elements have to have an ID with them.
And each Element has to have its own ID.
Check out the code, I am pretty sure that this is what you are wanting.

Good Luck
And let me know if you have any questions (or) if this is not what you want.

Carrzkiss
Here, this works as a stand-alone asp ("yesno.asp") file, you can embed what you need in your own doc.
<%@ Language=VBScript%>
<%Response.Buffer = true%>
<%
dim ynv, strYN
Response.Write	"<table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""0"" align=""center"">" & vbNewline & _
	"	<tr valign=""middle"">" & vbNewline & _
	"		<td bgcolor=""cyan"">" & vbNewline & _
	"			<form action=""yesno.asp"" method=""post"" name=""yesnoform"">" & vbNewLine & _
	"			<input type=""hidden"" name=""yf"" value=""part1"">" & vbNewLine & _
	"			<table border=""0"" width=""100%"" cellspacing=""1"" cellpadding=""4"">" & vbNewline & _
	"				<tr valign=""middle"">" & vbNewline & _
	"					<td colspan=""4"" align=""center"" bgcolor=""cyan"">" & vbNewLine & _
	"						<font size=""4"" color=""black"">&nbsp;<br><b>COMPENSATION</b><br>&nbsp;" & vbNewLine & _
	"						</font>" & vbNewLine & _
	"					</td>" & vbNewLine & _
	"				</tr>" & vbNewLine & _
	"				<tr valign=""middle"">" & vbNewLine & _
	"					<td colspan=""2"" bgcolor=""skyblue"" align=""right"">" & vbNewLine & _
	"						<font size=""2"" color=""navy"">Have you ever received compensation?&nbsp;&nbsp;" & vbNewLine & _
	"						</font>" & vbNewLine & _
	"					</td>" & vbNewLine & _
	"					<td colspan=""2"" bgcolor=""skyblue"" align=""left"">" & vbNewLine & _
	"						<input type=""radio"" name=""ynv"" value=""1"" checked>Yes" & vbNewLine & _
	"						<input type=""radio"" name=""ynv"" value=""0"">No" & vbNewLine & _
	"					</td>" & vbNewLine & _
	"				</tr>" & vbNewLine & _
	"			</table><br>" & vbNewLine & _
	"			<center><input type=""submit"" value=""Submit"">" & vbNewLine & _
	"			</form>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"	</tr>" & vbNewLine & _
	"</table>" & vbNewLine
if Request.Form("ynv")=1 then
	Response.Write	"<table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""0"" align=""center"">" & vbNewline & _
		"	<tr valign=""middle"">" & vbNewline & _
		"		<td bgcolor=""cyan"">" & vbNewline & _
		"			<form action=""yesno.asp"" method=""post"" name=""yesform"">" & vbNewLine & _
		"			<input type=""hidden"" name=""yf"" value=""part2"">" & vbNewLine & _
		"			<table border=""0"" width=""100%"" cellspacing=""1"" cellpadding=""4"">" & vbNewline & _
		"				<tr valign=""middle"">" & vbNewline & _
		"					<td colspan=""4"" align=""center"" bgcolor=""cyan"">" & vbNewLine & _
		"						<font size=""4"" color=""black"">&nbsp;<br><b>DETAILS</b><br>&nbsp;" & vbNewLine & _
		"						</font>" & vbNewLine & _
		"					</td>" & vbNewLine & _
		"				</tr>" & vbNewLine & _
		"				<tr valign=""middle"">" & vbNewLine & _
		"					<td colspan=""1"" bgcolor=""skyblue"" align=""center"">" & vbNewLine & _
		"						<font size=""2"" color=""navy"">If so, Private" & vbNewLine & _
		"						</font>" & vbNewLine & _
		"						<input type=""text"" size=""35"" maxlength=""35"" name=""yesPrivate"">" & vbNewLine & _
		"					</td>" & vbNewLine & _
		"					<td colspan=""1"" bgcolor=""skyblue"" align=""center"">" & vbNewLine & _
		"						<font size=""2"" color=""navy"">Where?" & vbNewLine & _
		"						</font>" & vbNewLine & _
		"						<input type=""text"" size=""35"" maxlength=""35"" name=""yesWhere"" class=""normaltxt"">" & vbNewLine & _
		"					</td>" & vbNewLine & _
		"					<td colspan=""1"" bgcolor=""skyblue"" align=""center"">" & vbNewLine & _
		"						<font size=""2"" color=""navy"">Year" & vbNewLine & _
		"						</font>" & vbNewLine & _
		"						<input type=""text"" size=""35"" maxlength=""35"" name=""yesYear"">" & vbNewLine & _
		"					</td>" & vbNewLine & _
		"					<td colspan=""1"" bgcolor=""skyblue"" align=""center"">" & vbNewLine & _
		"						<font size=""2"" color=""navy"">Previous Comp Participation Year?" & vbNewLine & _
		"						</font>" & vbNewLine & _
		"						<input type=""text"" size=""35"" maxlength=""35"" name=""yesDCYear"" class=""normaltxt"">" & vbNewLine & _
		"					</td>" & vbNewLine & _
		"				</tr>" & vbNewLine & _
		"			</table><br>" & vbNewLine & _
		"			<center><input type=""submit"" value=""Submit"">" & vbNewLine & _
		"			</form>" & vbNewLine & _
		"		</td>" & vbNewLine & _
		"	</tr>" & vbNewLine & _
		"</table>" & vbNewline
end if
if Request.Form("yf") = "part2" then
	Response.Write	Request.Form("yesPrivate") & "=yesPrivate<br>" & vbNewLine & _
		Request.Form("yesWhere") & "=yesWhere<br>" & vbNewLine & _
		Request.Form("yesYear") & "=yesYear<br>" & vbNewLine & _
		Request.Form("yesDCYear") & "=yesDCYear"
	Response.Flush
	Response.End
end if
%>

Open in new window

Craig.
He wants it to be in a Dropdown menu, and with no Button.
Basically like what I have provided.
The only thing that is missing from mine is the <%IF Statement%>
But, works none-the-less.

Carrzkiss
hi everybody and thanks to all of you for all your efforts. It is really appreciated.

Yes, Carrzkiss is right/ His code actually gave me what I was looking for.

My only concern is that there is way too much code for those 4 lines.

I will use it if I can't come up with something more compact.

Again, thanks all and especially you Carrzkiss for always being there.
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I agree with you Carrkiss, this is AWESOME with very, very efficient code.

Many thanks for  *always coming through for me.

Thanks a lot. I will continue to pray that God reward for all your assistance.
Sorry for late response - busy all day.
You are very welcome Sammy.
Have a great evening and continue to chase your coding dreams.

Carrkiss