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

 [RESOLVED - SET RADIOBUTTON DBA VALUE TO NULL]

Print topic Send  topic

Author Message
CodeChargeMVP

Posts: 473
Posted: 01/06/2011, 2:44 AM

Hi,

Sceneario: (the - represents the point of the radiobutton)

Yes - No -

option1 - option2 - option 3 -

Our client wants to be able to save the three values from the radiobutton to null(this means

by no choosing any of the three options).

�does anybody knows if the radiobutton object has any inconvenience to be recorded

to null when no one of the options gets selected?

I do ask this question because when saving the form the values doesn�t get recorded to null and still stand with the previous recorded value.

¿How do I set the db value to null when no one option from the radiobutton is selected?

I�ve find one helpful thread from 2006

http://forums.codecharge.com/posts.php?post_id=72211

_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/06/2011, 9:08 AM

I´ve made the following, besides to the radio button I´ve add a button with value "*",

then when the user clicks on this butoon the options from the radio button get unselected,

inside the for I set the value from a hidden button to 1 which will work as a control variable,

now on the before show event from the radiobutton I want to check the value of the hidden button

then if the button value is == 1 i´ll execute an update over the dba,

the problem is than I can´t get access to the hidden button, i´m tying it this way:


echo(the value is:).$myform->nameofthehiddenbutton->Value;

I´ve try it also with GetValue() but anything is showed,

¿is it possible than the value from the hidden button get lost when the user clicks the update button?


_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/06/2011, 9:43 AM

According to this instructions:

http://forums.codecharge.com/posts.php?post_id=72211

¿Why the line $Component->GetValue() does not return a null value when the options from the

radio button are all unselected and still show the last value recorded?


_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
Waspman

Posts: 948
Posted: 01/07/2011, 12:46 AM

Before insert custom script
_________________
http://www.waspmedia.co.uk
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/07/2011, 1:14 AM

Yes,on the before show from the radio button I´ll run a script which update the dba,

but I need a condition to control when no one of the radio buttons are selected,

$Component->Value does not return a different value when no one option is selected,

¿Any suggestion?

Quote Waspman:
Before insert custom script

_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
Waspman

Posts: 948
Posted: 01/07/2011, 6:14 AM

So do you want them to act like a radio button list, but capture the the value from each option?

Will it be feeding three separate fields?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/07/2011, 10:47 AM

No, please read it over my first message and the title name of the post.

I want than the dba field source control from the radio button get recorded as "NULL"

when no one option from the radio button is selected.


Quote Waspman:
So do you want them to act like a radio button list, but capture the the value from each option?

Will it be feeding three separate fields?

_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
datadoit
Posted: 01/07/2011, 11:30 AM

Okay, here's what it sounds like you want...

You have a radio control that is bound to a database field, correct?
So, when the record form is loaded, if it's an insert, then the radio
control value will be null anyways, and if it's an update, then the
radio control value will be that of the database (null or otherwise).
If it's an update, and if the value of the radio control isn't changed
from it's original database value, then set it to null. Correct?

Given the above scenario, then in the radio control's OnValidate event,
add this:

if ($Component->GetValue() == $Container->ds->f("YourField")) {
$Component->SetValue(""); //for MySQL, you could SetValue("null")
}

All you're doing is testing the value of the radio control field as it's
displayed and submitted against the value of the radio control as it is
from the database before the update.
CodeChargeMVP

Posts: 473
Posted: 01/11/2011, 3:31 AM

Ok,

Thank you datadoit I´ll check it out and give you some feedback.


_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/14/2011, 1:57 AM

hi datadoit,

I think it´s even easyest,

"You have a radio control that is bound to a database field, correct?"

Right.

"So, when the record form is loaded, if it's an insert, then the radio
control value will be null anyways"

On the first insert the radiobutton is recorded as NULL if the user doesn´t select
any of the option from the radiobutton (this behaviour is correct), if the user does select
any of the options within the radiobutton it´ll recorded in the database with his corresponding
value(this behaviour is correct) .

"and if it's an update, then the
radio control value will be that of the database (null or otherwise)."

Here it comes the behaviour than i wanna develop, if it´s an update and the user doesn´t select any option from the radiobutton IT SHOULD BE RECORDED AS NULL ON THE DBA.

So I think than the code has to be like you write.




Quote datadoit:
Okay, here's what it sounds like you want...

You have a radio control that is bound to a database field, correct?
So, when the record form is loaded, if it's an insert, then the radio
control value will be null anyways, and if it's an update, then the
radio control value will be that of the database (null or otherwise).
If it's an update, and if the value of the radio control isn't changed
from it's original database value, then set it to null. Correct?

Given the above scenario, then in the radio control's OnValidate event,
add this:

if ($Component->GetValue() == $Container->ds->f("YourField")) {
$Component->SetValue(""); //for MySQL, you could SetValue("null")
}

All you're doing is testing the value of the radio control field as it's
displayed and submitted against the value of the radio control as it is
from the database before the update.

_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 01/14/2011, 2:13 AM

if ($Component->GetValue() == $Container->ds->f("YourField")) {
$Component->SetValue(""); //for MySQL, you could SetValue("null")
}


I think the solution it´s about to capture the value from the radiobutton, but on the beforeshowevent $Component->GetValue() does not returl NULL or anything when no option from the radiobutton is selected, well that would be the solution on javascript
¿what would be a correct solution here on php?

in other words I need a code like this:

if($Component->GetValue() == ""){

THEN UPDATE DBAFIELD TO NULL

}





_________________
Best Regards
Entrepeneur | NT Consultant
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 04/04/2011, 2:31 PM

Finally Resolved using an ajax solution.


_________________
Best Regards
Entrepeneur | NT Consultant
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.

MS Access to Web

Convert MS Access to Web.
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.