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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Display of Text

Status
Not open for further replies.

hdog

Technical User
Mar 24, 2002
26
US
I am trying to look at a checkbox value in an access database and if False show no text and if True show static text. I have written the following code but can't get it to work. The code is pulling the true or false checkbox value from the db since I can get it to display on page. Can you help get this code working?

<%
if(String(report_fields.Fields.Item("do_not_contact").Value)==String("False"))
{Response.write("");
}
{Response.write("Do Not Contact");
}
%>

Thanks
 
I described the db value as a checkbox value but really meant it was a true/false field. Sorry for the confusion. I know this is simple but just seem to be having a mental block!
 
Is this Javascript or ASP?

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Javascript contained in an ASP page.
 
You asked for help in getting it to work (and it really belongs on the ASP forum), but you didn't explain what it does now and what you want to accomplish with the code.

Lee
 
Sorry if I didn't explain in sufficient detail...let me try again.

I have an access database with a table of records. One field in the table is a boolean (true/false) field. I am creating a recordset in my asp page that pulls data from the access table and displays it on the asp page (ie report_fields.Fields.Item("do_not_contact").Value). If the boolean field for a record is "True", I want it to display the text "Do Not Contact". If the record field is "False", I want it to display "". I didn't post the recordset information previously because I know the recordset is working correctly. I can get the Value of the boolean field to display on the asp page (displays the Text "True" or "False") but when I try to incorporate this into a conditional if.else statement it doesn't seem to recognize the text and always returns a "False" result. I'm suspecting there is a problem with the way I am treating the Value of the boolean field (string vs. number) but I have tried everything I can think of to no avail.

Does this help?
 
Never mind, I figured out my mistake. I was comparing to "True" when it should have been "1". Here was the final code:

<%
if(report_fields.Fields.Item("do_not_contact").Value=="1"){Response.Write("Do Not Contact");
}
{Response.Write("");
}%>

Ths simple things can sometimes seem so difficult.

Thanks for the help anyway.
 
hdog,

Maybe you need "else" as well after all the findings...
[tt] }[blue]else[/blue][/tt]

regards - tsuji
 
Hi,

I am having a problem as I know very little about javascript.

I have a form with 3 drop down boxes - the first box is a populated using thestandard <SELECT> tag.
The 2nd box is populated with values depending on the choice made in the 1st box, and the 3rd box depends on the choice in the 2nd.

This all works fine.
However, I want to be able to display some explanation text after the first drop down box - and the text will depend on the choice made in the first box.
This is where I have no idea!

Any help gratefully received!

My code so far:

<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();


<!-- Designer -->
arrItems1[1] = "Standard";
arrItemsGrp1[1] = 1;
arrItems1[2] = "Educational";
arrItemsGrp1[2] = 1;
<!-- End of Designer -->


<!-- CorelDraw Graphics Suite -->
arrItems1[3] = "Standard";
arrItemsGrp1[3] = 2;
<!-- End of CorelDraw Graphics Suite -->


<!-- Grafigo -->
arrItems1[4] = "Standard";
arrItemsGrp1[4] = 3;
<!-- End of Grafigo -->


<!-- Ventura -->
arrItems1[5] = "Standard";
arrItemsGrp1[5] = 4;
arrItems1[6] = "Educational";
arrItemsGrp1[6] = 4;
<!-- End of Ventura -->


<!-- Paradox Standalone -->
arrItems1[7] = "Standard";
arrItemsGrp1[7] = 5;
<!-- End of Paradox Standalone -->


<!-- Painter -->
arrItems1[8] = "Standard";
arrItemsGrp1[8] = 6;
arrItems1[9] = "Educational";
arrItemsGrp1[9] = 6;
<!-- End of Painter -->


<!-- WordPerfect Office Standard -->
arrItems1[10] = "Standard";
arrItemsGrp1[10] = 7;
arrItems1[11] = "Educational";
arrItemsGrp1[11] = 7;
<!-- End of WordPerfect Office Standard -->


<!-- WordPerfect Office Standard -->
arrItems1[12] = "Standard";
arrItemsGrp1[12] = 8;
<!-- End of WordPerfect Office Standard -->



var arrItems2 = new Array();
var arrItemsGrp2 = new Array();



<!-- Designer -->
arrItems2[2000] = "New Licence";
arrItemsGrp2[2000] = 1;
arrItems2[2001] = "Upgrade Licence";
arrItemsGrp2[2001] = 1;
arrItems2[2002] = "Maintenance";
arrItemsGrp2[2002] = 1;

arrItems2[2003] = "New Licence";
arrItemsGrp2[2003] = 2;
arrItems2[2005] = "Maintenance";
arrItemsGrp2[2005] = 2;
<!-- End of Designer -->


<!-- CorelDraw Graphics Suite -->
arrItems2[2006] = "New Licence";
arrItemsGrp2[2006] = 3;
arrItems2[2007] = "Upgrade Licence";
arrItemsGrp2[2007] = 3;
arrItems2[2008] = "Maintenance";
arrItemsGrp2[2008] = 3;
<!-- End of CorelDraw Graphics Suite -->


<!-- Grafigo -->
arrItems2[2009] = "New Licence";
arrItemsGrp2[2009] = 4;
<!-- End of Grafigo -->


<!-- Ventura -->
arrItems2[2010] = "New Licence";
arrItemsGrp2[2010] = 5;
arrItems2[2011] = "Upgrade Licence";
arrItemsGrp2[2011] = 5;
arrItems2[2012] = "Maintenance";
arrItemsGrp2[2012] = 5;

arrItems2[2013] = "New Licence";
arrItemsGrp2[2013] = 6;
<!-- End of Ventura -->


<!-- Paradox Standalone -->
arrItems2[2014] = "New Licence";
arrItemsGrp2[2014] = 7;
arrItems2[2015] = "Upgrade Licence";
arrItemsGrp2[2015] = 7;
<!-- end of Paradox Standalone -->


<!-- Ventura -->
arrItems2[2016] = "New Licence";
arrItemsGrp2[2016] = 8;
arrItems2[2017] = "Upgrade Licence";
arrItemsGrp2[2017] = 8;
arrItems2[2018] = "Maintenance";
arrItemsGrp2[2018] = 8;

arrItems2[2019] = "New Licence";
arrItemsGrp2[2019] = 9;
arrItems2[2020] = "Maintenance";
arrItemsGrp2[2020] = 9;
<!-- End of Ventura -->


<!-- WordPerfect Office Standard -->
arrItems2[2021] = "New Licence";
arrItemsGrp2[2021] = 10;
arrItems2[2022] = "Upgrade Licence";
arrItemsGrp2[2022] = 10;
arrItems2[2023] = "Maintenance - 1 year";
arrItemsGrp2[2023] = 10;
arrItems2[2024] = "Maintenance - 2 years";
arrItemsGrp2[2024] = 10;

arrItems2[2025] = "New Licence";
arrItemsGrp2[2025] = 11;
arrItems2[2026] = "Maintenance - 1 year";
arrItemsGrp2[2026] = 11;
arrItems2[2027] = "Maintenance - 2 years";
arrItemsGrp2[2027] = 11;
<!-- End of WordPerfect Office Standard -->


<!-- WordPerfect Office Professional -->
arrItems2[2028] = "New Licence";
arrItemsGrp2[2028] = 12;
arrItems2[2029] = "Upgrade Licence";
arrItemsGrp2[2029] = 12;
arrItems2[2030] = "Maintenance - 1 year";
arrItemsGrp2[2030] = 12;
arrItems2[2031] = "Maintenance - 2 years";
arrItemsGrp2[2031] = 12;
<!-- End of WordPerfect Office Professional -->




function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "-- please select --" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>
</head>

<body>
<form name="myChoices" method="post" action="corel_result.php">
<table width="100%" align="center">
<tr>
<td width="40%"> <div align="right"> Product</div></TD>
<td width="5%"> <div align="center">:</div></TD>
<td> <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>-- please select --</option>
<option value=1>Corel Designer</option>
<option value=2>CorelDraw Graphics Suite</option>
<option value=3>Corel Grafigo</option>
<option value=4>Corel Ventura</option>
<option value=5>Paradox Standalone</option>
<option value=6>Corel Painter</option>
<option value=7>WordPerfect Office Standard</option>
<option value=8>WordPerfect Office Professional</option>
</SELECT> </TD>
</TR>
<TR>
<TD><div align="right">Standard or Educational</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right">Licence Type</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=thirdChoice name=thirdChoice onchange="selectChange(this, myChoices.fourthChoice, arrItems3, arrItemsGrp3);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right"></div></TD>
<TD><div align="center"></div></TD>
<TD> </TD>
</TR>
<TR>
<TD><div align="right">Number of Licences Required</div></TD>
<TD><div align="center">:</div></TD>
<TD><INPUT TYPE=text SIZE=5 NAME=licence_numbers></TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD><INPUT TYPE=submit VALUE="Get Quote"></TD>
</TR>
</TABLE>
</form>
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top