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 -> Java

 document.forms.submit() Problem

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 05/05/2006, 9:28 AM

Hi

I am having a problem with using the js submit() functionality on a button (custom code on click). When selecting the save the page sometimes saves but more often than not it doesn't save and the data is lost (goes back to the original data). I tried using both of the below methods
document.FormName.submit(); and  
document.forms["FormName"].submit();

with the same reults for each (intermitten successful saves) has anyone else had this problem?

Any help would be much appreciated

thanks in advance

Rob
View profile  Send private message
matheus

Posts: 386
Posted: 05/05/2006, 10:22 AM

Looks if haven't had js error before the button.

Use Firefox and use javascript console to watch warning and errors.

Put some alerts before the submit to see if the code is always reacheable.

Hope it helps.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
robn

Posts: 70
Posted: 05/08/2006, 2:57 AM

Thanks for the reply Matheus

I've just tried it with Firefox console and no errors are returned. The code appears to run as the form refreshes after submit. but doesn't seem to hit the database the full code looks like this
{  
var result;  
result = window.confirm('Are you sure you wish to save this Software Support record?');  
if (result == true){  
document.forms["tblProject"].submit();  
window.location.href="CF2a.asp?ID=" + document.tblProject.PID.value + "&clientName=" + document.tblProject.clientName.value;  
}  
else {return false;  
}  
}

I am unsure if the code directly after the Submit could cause a problem (this piece of code appears to run every time)?

Thanks again

Rob
View profile  Send private message
matheus

Posts: 386
Posted: 05/08/2006, 4:45 AM

Hm...

robn, to test I will make a 'debug' of your code. Something like this:

  
{    
var result;    
result = window.confirm('Are you sure you wish to save this Software Support record?');    
alert('result');  
if (result == true){    
alert('inside if');  
document.forms["tblProject"].submit();    
alert('after submit');  
window.location.href="CF2a.asp?ID=" + document.tblProject.PID.value +   
"&clientName=" + document.tblProject.clientName.value;    
alert('location href');  
}    
else {alert('inside else'); return false;    
}    
}  

Look the form's action, or maybe you need get the window.location.href line in a variable before the submit, to get controls value.


_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
robn

Posts: 70
Posted: 05/08/2006, 6:31 AM

Thanks for the debug script Matheus I receive alerts from all the alerts including location href, but still the database is not always updated.

I'm wondering if there could be an easier way to do this using CCStudio? What I need to do is basically submit the data and update the URL to point to the same page but update the clientname parameter to the current clientname (if this has changed). I can't seem to find a way to do this in CCS. Currently when you set the redirect after submit to teh current page the string looks like this

Redirect = "CF2a.asp?" & CCGetQueryString("QueryString", Array("ccsForm"))

But I can't seem to find a way to add the parameters onto the end of it.

Thanks

Rob
View profile  Send private message
matheus

Posts: 386
Posted: 05/08/2006, 7:47 AM

Hm... It's just add a parameter or replace a parameter? If was only add a parameter I think it's easy to do.

It's the same idea that it's used to after insert some record get the auto-incremented value and redirect with the parameter.

Look in Java:
In Event: afterExecuteInsert.
  
int id =  Integer.parseInt(String.valueOf(e.getRecord().getControl("clientName").getValue()); //here recover your value  
e.getPage().setRedirectString(e.getPage().getRedirectString()+"&ID="+id);  

So it will set Redirect String with the ID in final.

Hope it help, sorry my english.

If isn't this I couldn't understand what you need.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
robn

Posts: 70
Posted: 05/08/2006, 9:25 AM

Thanks again Matheus

i have found a way to resolve the issue using CCS, i changed the code in the Operation method from:
Redirect = "CF2a.asp?" & CCGetQueryString("QueryString", Array("ccsForm"))
to
Redirect = "CF2a.asp?" & CCGetQueryString("Form", Array("ccsForm"))
plus removed parameters that I did not need in the Array.

Changing the GetQueryString to "Form" means that it Retrieves the POST input parameter value so refreshes/updates the parameters with the correct values.

thanks again for your help

Rob
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.