CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Listbox does not display Default Value

Print topic Send  topic

Author Message
raknuth


Posts: 67
Posted: 01/24/2011, 1:02 PM

Hi. I have a MySQL field named 'is_active'. It is type ENUM, with values of 'yes','no'. The default value of the MySQL field is 'no'. I used the application Builder to create a Maintenance form, and on this form created a Listbox tied to the MySQL field. The Listbox's DataSourceType = ListOfValues and the values are 'yes;yes;no;no'. The DefaultValue for the Listbox is 'no'.

When I wish edit an existing record, the Listbox displays the proper value. When I wish to add a new record, the default value of 'no' does not appear as Selected in the list.

I have a similar problem with Textbox controls, where I have created a default value for a control and it does not populate the control with the value when the record form is used to add a new record.

What am I doing wrong?
View profile  Send private message
damian

Posts: 838
Posted: 01/26/2011, 4:06 AM

i spent some time trying to get this to work and couldnt. in the help file it says the following:
Default [Value]  
Specify a default value to be used for the control if no value is otherwise specified.  
i wonder if that means that if the user left the list box with Select Value option highlighted and you set the default to no it might actually enter no into db even though it wasnt selected on screen?
i tried to test quickly but was unsuccessful so maybe it just doesnt work?
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
raknuth


Posts: 67
Posted: 01/26/2011, 9:21 AM

Damian, I believe that your assumption is correct. So I need to look at this problem from an HTML, PHP or Javascript point of view and rephrase my request.

Can anyone help me with a graceful way to?

1- populate Textbox1 with a default value when the maintenance form is rendered in the Insert Record mode.
2 - populate Textbox1 with the value retrieved from the MySQL data when the maintenance form is rendered in the Update record mode.
View profile  Send private message
datadoit
Posted: 01/26/2011, 11:17 AM

First thing to check... For the Default Value property for your control,
are you using quotes around the value? Such as "no".
andrewi

Posts: 162
Posted: 01/26/2011, 1:00 PM

I've just tested this (in asp) and the default value works as (I) expected: it sets the value of the combobox on a new record. I've also tried creating a new combobox with 'yes;yes;no;no' as list of values, and default of "no" - and it defaults as expected on insert.

It might be an idea to raise it with CC Support. or you could try it quickly on a form on a new page, e.g. a Search form, without bothering to bind it to the database at all. Just in case there's something odd about the form in question. When the form is in insert mode I don't believe any database connection is made, so the database settings should have no influence over the default value.

A different quick solution: reverse the order of the list of values ('no;no;yes;yes'), and remove any other value in the 'SELECT properties' (right-click the combo box in Design window). That way 'no' will be selected by default simply because it's first in the list.
View profile  Send private message
raknuth


Posts: 67
Posted: 01/26/2011, 2:07 PM

Thanks for the replies on the topic of the default values for the Listbox. I have solved the initial problem. The HTML for the Listbox, as generated by the Application Builder, looks like this:

<select id="themesis_active" name="{is_active_Name}">
<option selected value="No">Select Value</option>
{is_active_Options} // where these options are ListOfValues = "Yes";"Yes";"No";"No"
</select>

I only had to change the "Select Value" text to "No" and the control works as expected. The solution is easy, as the values for the list are manually created.

I still need a solution to presenting default text for a Textbox. Here is the HTML for a representative sample:

<input id="themespage_border_color" onclick="colorPicker(event)" value="{page_border_color}" maxlength="7" size="7" name="{page_border_color_Name}" style="background-color: {page_border_color}">

When the form (themes_maint.php) is In the EditMode, I wish the control to retrieve the value from the MySQL table. In the AddMode, i wish the control to display on screen and save as a default the value #cccccc.
View profile  Send private message
damian

Posts: 838
Posted: 01/26/2011, 3:41 PM

Quote raknuth:
I only had to change the "Select Value" text to "No" and the control works as expected. The solution is easy, as the values for the list are manually created.

ha - good - i had tried removong the whole selceted="Yes" and that didnt work for me
so the answer is to change "Yes" to "No"

Quote raknuth:
I still need a solution to presenting default text for a Textbox.

go to textbox -> data -> default value and set the value inside ' ' eg '#C1C1C1'
that should work

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
raknuth


Posts: 67
Posted: 01/26/2011, 5:35 PM

Perhaps I was unclear in stating my need. Getting the Default Value of the control to write to MySQL upon the Insert event is not the problem. I also need to have that Default Value appear in the Textbox as 'suggested text' when the form is in the AddMode, before the Insert event happens.

In a Listbox, there is an <option selected value="">Something</option> parameter. As long as I change Something to a string of text identical to the Default Value, I get what I want - a suggestion to the user and a value written to the MySQL table.

In a Textbox, there is no such option. There is only a value="" parameter. The CSS Application Builder fills in this value with the name of the control within curly braces, as follows:

<input id="themescontent_bg_color" onclick="colorPicker(event)" value="{content_bg_color}" maxlength="7" size="7" name="{content_bg_color_Name}" style="background-color: {content_bg_color}">

In the AddMode, there is no data; the control displays this empty value. So my hands are tied in suggesting another value. I need to suggest another value, and that value will also serve as the default value for the control.

Thanks for hanging in there with me...
View profile  Send private message
damian

Posts: 838
Posted: 01/26/2011, 7:57 PM

i tested it and on mine it worked - i did your scenario exactly - set the Default to be #CCCCC

go to textbox (in your page) -> data -> default value and set the value inside ' ' eg '#C1C1C1'
that should work

make sure you have those single quotation marks aroudn your text.
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
raknuth


Posts: 67
Posted: 02/01/2011, 9:07 AM

Damian, your solution worked exactly as defined. As single quote around the default text populates the textbox with that value when the form is in the AddMode. The retrieved data value populates the textbox when the form is in the Edit mode.

Thank you.
View profile  Send private message

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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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