close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

formtoolkit applied to page created with data assist

Thread began 6/04/2011 3:00 am by Base5 Designs | Last modified 6/06/2011 2:02 pm by Jason Byrnes | 2930 views | 8 replies |

Base5 Designs

formtoolkit applied to page created with data assist

hi there i am really stuggling with this.

i have pages created with datya assist using a template.

all pages are created and working ok, i am now trying to apply client validation.

the form submits without validating i mange to carch the following js error just before the redirect when the form is submitted:

WAAlertErrors is not defined

i'm assuming that because the page is based on a template the file that is needed for the validation is not included in the page.

how do i work arround this, or alternativly what do i need to include manually to allow the validation to work

Sign in to reply to this post

Base5 Designs

Ive done a search across my whole site and it only finds WAAlertErrors in the page i have the validation applied too, so i take it i am missing some files or something??? how can this be called if it is not defined anywhere???

Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of your page so I can take a look at the code.

Sign in to reply to this post

Base5 Designs

Hi Jason

after adding the the client validation from the toolbar this is the full page code that is generated.

firebug reports the following js error: WAAlertErrors is not defined
1
Line 3

although you have to press escape just after submitting to catch this as it redirects back to the results page...

<?php require_once('../../Connections/albionwines.php'); ?>
<?php require_once("../../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $albionwines;
$WA_table = "drinkcats_dct";
$WA_sessionName = "WADA_Insert_drinkcats_dct";
$WA_redirectURL = "../../drinkcats_dct_Results.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "id_dct";
$WA_fieldNamesStr = "title_dct";
$WA_fieldValuesStr = "".((isset($_POST["title_dct"]))?$_POST["title_dct"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_albionwines;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/index-admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Insert Drink Category</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../../CSSMenuWriter/cssmw/menu.js"></script>
<style type="text/css" media="all">
<!--
@import url("../../CSSMenuWriter/cssmw/menu.css");
-->
</style>
<!--[if lte IE 6]>
<style type="text/css" media="all">
@import url("../CSSMenuWriter/cssmw/menu_ie.css");
</style>

<style type="text/css" media="all">
img, div, ul, li, span, a {
behavior: url("../CSSMenuWriter/cssmw_images/iepngfix.htc");
}
</style>

<![endif]-->
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<link href="../../WA_DataAssist/styles/Traditional_Slate.css" rel="stylesheet" type="text/css" />
<link href="../../WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function WAtrimIt(theString,leaveLeft,leaveRight) {
if (!leaveLeft) {
while (theString.charAt(0) == " ")
theString = theString.substring(1);
}
if (!leaveRight) {
while (theString.charAt(theString.length-1) == " ")
theString = theString.substring(0,theString.length-1);
}
return theString;
}

function WAFV_GetValueFromInputType(formElement,inputType,trimWhite) {
var value="";
if (inputType == "select") {
if (formElement.selectedIndex != -1 && formElement.options[formElement.selectedIndex].value && formElement.options[formElement.selectedIndex].value != "") {
value = formElement.options[formElement.selectedIndex].value;
}
}
else if (inputType == "checkbox") {
if (formElement.length) {
for (var x=0; x<formElement.length ; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radio") {
if (formElement.length) {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radiogroup") {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (inputType == "iRite") {
var theEditor = FCKeditorAPI.GetInstance(formElement.name) ;
value = theEditor.GetXHTML(true);
}
else {
var value = formElement.value;
value=value.replace(/<p>(\&\#160\;)*<\/p>/,"");
}
if (trimWhite) {
value = WAtrimIt(value);
}
return value;
}

function WAAddError(formElement,errorMsg,focusIt,stopIt) {
if (document.WAFV_Error) {
document.WAFV_Error += "\n" + errorMsg;
}
else {
document.WAFV_Error = errorMsg;
}
if (!document.WAFV_InvalidArray) {
document.WAFV_InvalidArray = new Array();
}
document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
if (focusIt && !document.WAFV_Focus) {
document.WAFV_Focus = focusIt;
}

if (stopIt == 1) {
document.WAFV_Stop = true;
}
else if (stopIt == 2) {
formElement.WAFV_Continue = true;
}
else if (stopIt == 3) {
formElement.WAFV_Stop = true;
formElement.WAFV_Continue = false;
}
}

function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,trimWhite,inputType) {
var isValid = true;
if (formElement.length && inputType.toLowerCase()!="radio" && inputType.toLowerCase()!="select") formElement=formElement[0];
if (!document.WAFV_Stop && !formElement.WAFV_Stop) {
var value=WAFV_GetValueFromInputType(formElement,inputType,trimWhite);
if (value == "") {
isValid = false;
}
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
</script>
<!-- InstanceEndEditable -->
</head>

<body>
<div id="adminmenu">
<?php require_once("../../CSSMenuWriter/cssmw/menu.php"); ?>
</div>
<div id="admincontent">
<!-- InstanceBeginEditable name="admincontent" -->

<div class="WADAInsertContainer">
<form action="Insert.php" method="post" name="WADAInsertForm" id="WADAInsertForm" onsubmit="WAValidateRQ(document.WADAInsertForm.title_dct,'-Title is required',document.WADAInsertForm.title_dct,0,true,'text');WAAlertErrors('The following errors were found','Correct invalid entries to continue',true,false);return document.MM_returnValue">
<div class="WADAHeader">Insert Drink Category</div>
<div class="WADAHorizLine"><img src="../../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Title:</th>
<td class="WADADataTableCell"><input type="text" name="title_dct" id="title_dct" value="" size="32" /></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="../../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="../../WA_DataAssist/images/Slate/Traditional_insert.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="../../drinkcats_dct_Results.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../../WA_DataAssist/images/Slate/Traditional_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />
</div>
</form>
</div>
<!-- InstanceEndEditable -->
</div>
</body>
<!-- InstanceEnd --></html>

Sign in to reply to this post

Jason ByrnesWebAssist

please compress the page into a zip archive rather than pasting the page code to your message.

Sign in to reply to this post

Base5 Designs

file in zip as requested

Attached Files
client_validation_insert_page_requiredfield.zip
Sign in to reply to this post

Jason ByrnesWebAssist

add the following code just before the closing </script> tag:

function WAAlertErrors(errorHead,errorFoot,setFocus,submitForm,allowOverride)  { 
if (!document.WAFV_StopAlert) {
document.WAFV_StopAlert = true;
if (document.WAFV_InvalidArray) {
document.WAFV_Stop = true;
var errorMsg = document.WAFV_Error;
if (errorHead!="")
errorMsg = errorHead + "\n" + errorMsg;
if (errorFoot!="")
errorMsg += "\n" + errorFoot;
document.MM_returnValue = false;
if (document.WAFV_Error!="") {
if (allowOverride) {
if (confirm(errorMsg.replace(/&quot;/g,'"'))) {
document.MM_returnValue = true;
return;
}
}
else {
alert(errorMsg.replace(/&quot;/g,'"'));
}
}
else if (submitForm)
submitForm.submit();
if (setFocus && document.WAFV_Focus) {
if (document.getElementById(document.WAFV_Focus.name+"___Config") && document.WAFV_Focus.type.toLowerCase() == "hidden") {
var theEditor = FCKeditorAPI.GetInstance(document.WAFV_Focus.name);
theEditor.EditorWindow.focus();
setTimeout("setTimeout('document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1);
}
else {
document.tempFocus = document.WAFV_Focus;
setTimeout("document.tempFocus.focus();setTimeout('document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1);
}
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
}
for (var x=0; x<document.WAFV_InvalidArray.length; x++) {
document.WAFV_InvalidArray[x].WAFV_Stop = false;
}
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
if (submitForm) {
submitForm.submit();
}
document.MM_returnValue = true;
}
document.WAFV_Focus = false;
document.WAFV_Error = false;
document.WAFV_InvalidArray = false;
}
}
Sign in to reply to this post

Base5 Designs

thanks for your reply, the code works

although thats a lot of code to be adding after applying the behaviour. i assume that the extension should be adding this too the page, is this a bug in the extension?

or is it an issue because i am using a template?

Sign in to reply to this post

Jason ByrnesWebAssist

Honestly, I cannot say why the code is not being added. I cannot reproduce the problem on my end. if it where a problem with the template, the page would be mising more than the single function, so i dont believe it is a problem with the template.

perhaps try uninstalling form builder than installing again and deleting the dreamweaver cache file:
common_installation_issues.pdf

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...