473,231 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Initial value form field generation problem

I've got a system that automatically generates a form. I have it set
up so that the backend will return to the inital form page with an
error object in sessions data (assuming the backend detected invalid
data or required fields not filled in) and the frontend will generate
an initial value of items WITHOUT errors (so the user doesn't have to
reenter valid info).

This is the problem. The frontend generates the initial value
attribute 'value="(<field_name_here>)"', so if the field's name was
'Phone' it would generate 'value="(Phone)"' instead of
'value="555-555-5555"'.

I've checked what the POST method is sending the backend, and it's ok.
I also checked what the backend is sending the frontend through the
session varialbes, and it's ok too. So my only thought is it's either
somewhere in the code or it's MSIE 6.
Here's the code

It is based upon 3 objects:

1) fieldArray - matrix associative array of all fields of the form and
eache fields properties (ie. type, name, initial value, etc)
2) error->errorArray - array in error class with the names of each
error producing field (ie. required field not filled in, fields with
invalid data, etc.)
3) error->hasErrors - boolean, true if there are errors in errorArray
4) 3 objects (account,order,signup) each with an array of data from the
user (eventually put into mySQL db)

NOTE: this is in a foreach statement that walks the fieldArray

-----PHP Code-----
//check for type, if text, do this...
elseif($fieldArray[type] == 'text') {

//begin input element
$_element = "<input type=\"text\" name=\"$fieldArray[name]\" ";

//check for errors - if there are errors, but this field isn't in
// the list of fields with errors, do this...
if($error->hasErrors() &&
array_search($fieldArray[name],$error->getErrorArray())==false) {

//if data is in the account object, add the value attribute to
// the input field with the value from the object as the
// attribute value
//NOTE: the getField functions return false if the field isn't
// found, they return the value of the field if it is found
if($account->getField($fieldArray[name]) != false) {
$_element .= "value=\"$account->getField($fieldArray[name])\" ";
}

//if data is in the orderobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($order->getField($fieldArray[name]) != false) {
$_element .= "value=\"$order->getField($fieldArray[name])\" ";
}

//if data is in the signupobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($signup->getField($fieldArray[name]) != false) {
$_element .= "value=\"$signup->getField($fieldArray[name])\" ";
}
}

// finish the input field
$_element .= '/>';
}
-----PHP Code-----

Thanks for taking a look at this,
-TekWiz

Jul 17 '05 #1
3 2741
TekWiz wrote:
I've got a system that automatically generates a form. I have it set
up so that the backend will return to the inital form page with an
error object in sessions data (assuming the backend detected invalid
data or required fields not filled in) and the frontend will generate
an initial value of items WITHOUT errors (so the user doesn't have to
reenter valid info).

This is the problem. The frontend generates the initial value
attribute 'value="(<field_name_here>)"', so if the field's name was
'Phone' it would generate 'value="(Phone)"' instead of
'value="555-555-5555"'.

I've checked what the POST method is sending the backend, and it's ok.
I also checked what the backend is sending the frontend through the
session varialbes, and it's ok too. So my only thought is it's either
somewhere in the code or it's MSIE 6.
Here's the code

It is based upon 3 objects:

1) fieldArray - matrix associative array of all fields of the form and
eache fields properties (ie. type, name, initial value, etc)
2) error->errorArray - array in error class with the names of each
error producing field (ie. required field not filled in, fields with
invalid data, etc.)
3) error->hasErrors - boolean, true if there are errors in errorArray
4) 3 objects (account,order,signup) each with an array of data from the
user (eventually put into mySQL db)

NOTE: this is in a foreach statement that walks the fieldArray

-----PHP Code-----
//check for type, if text, do this...
elseif($fieldArray[type] == 'text') {

//begin input element
$_element = "<input type=\"text\" name=\"$fieldArray[name]\" ";

//check for errors - if there are errors, but this field isn't in
// the list of fields with errors, do this...
if($error->hasErrors() &&
array_search($fieldArray[name],$error->getErrorArray())==false) {

//if data is in the account object, add the value attribute to
// the input field with the value from the object as the
// attribute value
//NOTE: the getField functions return false if the field isn't
// found, they return the value of the field if it is found
if($account->getField($fieldArray[name]) != false) {
$_element .= "value=\"$account->getField($fieldArray[name])\" ";
}

//if data is in the orderobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($order->getField($fieldArray[name]) != false) {
$_element .= "value=\"$order->getField($fieldArray[name])\" ";
}

//if data is in the signupobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($signup->getField($fieldArray[name]) != false) {
$_element .= "value=\"$signup->getField($fieldArray[name])\" ";
}
}

// finish the input field
$_element .= '/>';
}
-----PHP Code-----

Thanks for taking a look at this,
-TekWiz

Yup - I think i know the problem, assuming i've interpreted your post
correctly you want to be able perform server side validation and then
redirect the user to a redrawn form with validation error messages +
show the user the content of the form as the user submitted it.

To do this you have to use objects and sessions and pass an object that
encapsulates the form in the session. sounds complicated but it a'int
really, you just have cope with the concept of an asynchrounous
environment.

If you want some help i'll put some php source on my website that may
help. email me.

Chris

Jul 17 '05 #2
> Yup - I think i know the problem, assuming i've interpreted your post
correctly you want to be able perform server side validation and then redirect the user to a redrawn form with validation error messages +
show the user the content of the form as the user submitted it.

To do this you have to use objects and sessions and pass an object that encapsulates the form in the session. sounds complicated but it a'int really, you just have cope with the concept of an asynchrounous
environment.

If you want some help i'll put some php source on my website that may help. email me.

Chris


Sorry about the misunderstanding, but I've already got the sessions
part down. It passes everything properly, but it doesn't print it
properly. ie. instead of printing <input name="name" type="text"
value="John Doe" /> (where John Doe is in the object), it prints
<input name="name" type="text" value="(Name)" /> (literally, with the
parentases)

Jul 17 '05 #3
::Solved::

The problem here is that PHP doesn't like methods in strings (I was
treating them as variables; which they weren't.

The solution is to use the concatonation function '.' between the
string and the functions.

--TekWiz

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dsnyder | last post by:
This HTML has a bit of Javascript at the end that puts the initial focus on the userID field. It works great on Windows2000 running IE6, but the initial focus never goes to the userID field on...
6
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works...
2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
9
by: Paradigm | last post by:
I am using an Access2K front end to a MYSQL database. If I enter a new record in a continuous form the record appears as #deleted as soon as I move to a different record in the form until I requery...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
4
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
3
by: Neekos | last post by:
Hey guys, I have a table that is linked to an Excel spreadsheet that imports a few different fields such as last name, first name, etc... i also have a form(frmBook) with a subform(frmSheet)...
1
by: jsaps33 | last post by:
Hi All, I'm wondering how I would change an initial value to a blank value if nothing gets entered into the text field. I have a form with multiple fields that visitors can enter data in to get...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.