CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> General/Other

 udateDB problemem

Print topic Send  topic

Author Message
delacosta45

Posts: 5
Posted: 03/12/2009, 4:16 AM

:-)I have problem with Ajax UpdateDB feature.

I have a form named as Client wich insert controls value into database.To some controls of the form i set up an ajax updateDB with insert operation to insert value into another table of my database.

My problem is that while the form is giving error because of empty value in controls wich are required, the ajax UpdateDB pass and insert the value to database what mean that if the user correct the form by giving required value Update DB will insert value again in its own table.i don't want UpdateDB to insert in DATABASE if the form is still giving error message for reqired value for the form
View profile  Send private message
damian

Posts: 838
Posted: 03/12/2009, 5:06 AM

you need to do some form validation on the javascript/ajax side of things before you let the ajax insert into db. you have to check that the non-ajax fields are all valid before allowing the ajax fields to update the table....
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
damian

Posts: 838
Posted: 03/12/2009, 10:38 PM

Quote :
Thanks for you response Damian
How do i do that please?

sorry delacosta - i know very little about javascript and ajax - if you are going to use one form to insert data via 2 different methods i think you might be making lots of work for yourself. try some resources like: javascript.internet.com or the forums of the particular ajax modules you are using....

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

Posts: 242
Posted: 03/13/2009, 7:15 PM

Hello delacosta45,

Here you have some resources with validation examples that you can adapt to your needs:

1.- JavaScript Form Validation: http://www.tizag.com/javascriptT/javascriptform.php
2.- Creating a JavaScript Validation object:
http://www.htmlgoodies.com/beyond/javascript/article.php/11877_3697716_2
3.- If your form is complex you can try this JavaScript Class to validate the user input:
http://www.javascript-coder.com/html-form/javascript-form-validation.phtml

Hope this help
Best regards
joejac
View profile  Send private message
delacosta45

Posts: 5
Posted: 03/14/2009, 4:10 AM

Thanks joejac
I read all what you send to me but it couldn't help.I then decided to retrieve on the return page after operation on server sucess ,all value i need to insert to databese so that they will be insert in database by this newpage.But how to retreive it on this page?
View profile  Send private message
damian

Posts: 838
Posted: 03/14/2009, 4:10 PM

can you explain why you submit some elements with php/form and others with ajax?

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

Posts: 242
Posted: 03/14/2009, 5:20 PM

Hello delacosta45,

Let me explain what I always do:

1.- I generate a base application, using the Application Builder, to use it as advanced starting point for continuing the development . The Application Builder facilitates the task very much and it takes care of basic validation by itself. For example If I try to enter a letter in a numeric field CCS validates the input and issue an error, not at javascript client level but at server level, which I think it is better.

2. If I need to do a more in depth validation, for example I do not what to delete a record from a menu table if it has child menu items under this, so I do the following:

2.1 For example, for my menu Record form I add the following code in: Record: menu - Properties - Events - Before Delete - Custom Code:

$menu_NO = CCGetFromGet("menu_no", 0); // Get the menu number to be deleted
$db = new clsDBConnection1(); // Open the connection
$SQL = "SELECT COUNT(*) FROM menu WHERE parent_menu_no=".$menu_NO; // Counts the number of menu Items underneath
$Result = CCGetDBValue($SQL, $db); // Get the result
if ($Result > 0) { // Check if there are more than zero items
$menu->DeleteAllowed = false; // Inform the component that Delete is not allowed
$menu->Errors->addError("There are ".$Result." items under this menu category, please delete them first"); //Error message using addError provided by CCS4
}

2.2 I double check before executing the previous event custom code if the user is sure he/she wants to delete a record by adding the following in Properties-Events-Button:Button_Delete-Client-On Click - Add Action - Confirmation Message:

"Are you sure you want to delete this record?, this operation can not be undone"

An the user will get that message before continue with the delete operation.

The good of CCS4 is that you get a lot of other things when click "Add Action" you get "Validate" too, like:
Validate: Entry, Form, Maximum Length, Maximum Value, Minimum Length, Minimum Value, Required Value.

You have to study, experiment and see the results. CCS has a lot of nice possibilities but it requires time, study, practice and patience.

I hope my example can help you and gives you an Idea of what can you do to validate on the server before executing a button of a form. Sorry if I can not provide with more information, I am not an expert, I am learning CCS too and I do not know AJAX :-)

Best regards
joejac
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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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