CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Hide Textbox and Label based on Listbox value (Javascript onChange)

Print topic Send  topic

Author Message
datadoit.com
Posted: 09/13/2007, 7:30 AM

CCS3.2.0.2; PHP5; MySQL5; Apache2

I have a record form with a listbox. Just below the listbox row I have
a textbox and an accompanying field label.

Ex:

Student Status: [Select Status]
{ExplanationLabel} |Explanation|

In the record's BeforeShow event, I have:

if ($Container->ds->f("StudentStatus") == "Expelled") {
$Container->ExplanationLabel->Visible = true;
$Container->Explanation->Visible = true;
}
else {
$Container->ExplanationLabel->Visible = false;
$Container->Explanation->Visible = false;
}

Easy enough, as long as the record is submitted on server side. What
I'd like to do now via javascript is dynamically show or hide both the
Label and the Textbox based on the value of the Listbox, using the
Client->OnChange event for the Listbox.

How can I work this magic in CCS?
datadoit.com
Posted: 09/14/2007, 10:41 AM

datadoit.com wrote:
> CCS3.2.0.2; PHP5; MySQL5; Apache2
>
> I have a record form with a listbox. Just below the listbox row I have
> a textbox and an accompanying field label.
>
> Ex:
>
> Student Status: [Select Status]
> {ExplanationLabel} |Explanation|
>
> In the record's BeforeShow event, I have:
>
> if ($Container->ds->f("StudentStatus") == "Expelled") {
> $Container->ExplanationLabel->Visible = true;
> $Container->Explanation->Visible = true;
> }
> else {
> $Container->ExplanationLabel->Visible = false;
> $Container->Explanation->Visible = false;
> }
>
> Easy enough, as long as the record is submitted on server side. What
> I'd like to do now via javascript is dynamically show or hide both the
> Label and the Textbox based on the value of the Listbox, using the
> Client->OnChange event for the Listbox.
>
> How can I work this magic in CCS?
----------------------------------

Folks are hootin' and hollerin' about how CCS can't do AJAX and no one
has done javascripting like this before?
Zye

Posts: 56
Posted: 09/22/2007, 7:26 PM

Hi Datadoit

I needed to show some text on listbox select. I found a great solution, after some hard Net trawling. Thanks to the originator glenngv.
http://codingforums.com/archive/index.php?t-51072.html
Another one using div containers. Could hide both field and label. Didn't work as well for me. Maybe a workaround. http://www.codingforums.com/archive/index.php?t-51417.html

  
<html>  
<head>  
<script type="text/javascript">  
var arr = new Array();  
arr[0] = '';  
arr[1] = 'This is a <a href="http://www.google.com/">link</a>.';  
arr[2] = 'This is in line 1.<br />This is in line 2.';  
arr[3] = '<span class="redmsg">This text uses a red Verdana font.</span>';  
//...and so on  
</script>  
<style type="text/css">  
.redmsg {font:normal 12px Verdana; color:red;}  
</style>  
</head>  
<body>  
<form>  
<select name="s" onchange="document.getElementById('desc').innerHTML=arr[this.selectedIndex]">  
<option value="">Select one</option>  
<option value="item 1">item 1</option>  
<option value="item 2">item 2</option>  
<option value="item 3">item 3</option>  
</select>  
<div id="desc"></div>  
</form>  
</body>  
</html>  

Hope this helps.
Cheers!
View profile  Send private message
datadoit.com
Posted: 09/24/2007, 8:09 AM

Zye wrote:
> Hi Datadoit
>
> I needed to show some text on listbox select. I found a great solution, after
> some hard Net trawling. Thanks to the originator glenngv.
> http://codingforums.com/archive/index.php?t-51072.html
> Another one using div containers. Could hide both field and label. Didn't work
> as well for me. Maybe a workaround.
> http://www.codingforums.com/archive/index.php?t-51417.html
>
----------------------------

Yes, this definitely looks like it'll do the trick. I'll CodeChargidize
it (that's a Bush-like word) and report back.

Thanks.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.