Parse form variable to insert in my query
I have a report where I want to group my output. The only
problem is the field I want to group by comes in as a comma
deliimeter from the form.
If I use the
in() function it doesnt group the output correctly.
<cfoutput>#form.id#</cfoutput><br><br>
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id in (#form.id#)
</cfquery>
<cfoutput query="que" group="id">
#id#<br>
<cfoutput>#name#<br></cfoutput>
</cfoutput>
Output -
2
Jones
2
Smith
But if I use one form value at a time it correctly groups my
output:
<cfquery name="que" datasource="mydsn">
SELECT *
FROM myTable
WHERE id = 6
</cfquery>
Output -
2
Jones
Smith
Please advise how I can take the form values and input them
one at a time in my cfquery?
I assume I need to parse the
form.id output and then loop through each value to insert
into my cfquery but not sure how I can do this?
quote:
Originally posted by:
drforbin1970
Also, you don't need nested CFOUTPUTs.
While you don't need nested cfoutputs for grouping,
you do if you want the group ID header to work properly and show
up - it's even in the CFDOCs and the only way I have ever
easily grouped with headers.
Similar Messages
-
CF Set form.variable for query and Next/Previous pages error
I have a CF form with a select that posts to a CF "action" page.
On the action page I: CFSET ItemNumber=#form.ItemNumber#
I CFOUTPUT the 'ItemNumber' into the CFQUERY (which is an Inner Join dependant on the '#ItemNumber#')...
All of the above works just fine and displays the database fields in color alternating rows, per the rest of the code.
Here's the problem:
I'm displaying 40 rows on a page per "Next and Previous" code. (CFPARAM name="start" default="1" and CFPARAM name="disp" default="40" along with the rest of the NextN code in the header and body). This does display 40 rows on the page and puts a link at the bottom of the page "Next 40 Rows", etc.
Note: I'm only querying the database once and using the query (query name="data") to populate the table rows And the NextN code (CFOUTPUT name="data") And (CFIF start + disp GREATER THAN data.RecordCount, etc)...
The problem happens when you click the "Next 40 Rows" link to display the 2nd page of rows. Since (I'm assuming) this NextN code is 're-reading' the same page from top to bottom, an error is thrown when the code tries to read the CFSET ItemNumber=#form.ItemNumber# at the top of the page.
With the #form.ItemNumber# on this action page Originally coming from the previous posting of the form to this action page, when the "Next 40 Rows" link is clicked and the NextN code re-reads this action page - the CFSET ItemNumber (#form.ItemNumber) is not getting populated and throws the error...
I hope I've not made this sound confusing.
I can get the NextN code to work when I'm just querying the database without "flying in" a form variable. But when I CFSET a variable (#form.ItemNumber#) that is inserted into the query, the second page of the NextN throws an error and doesn't display.
I would include the page code here but it would be fairly lengthy and, as well, the NextN code is a 'standard' CF code -- I've narrowed the problem down to the above "Element is undefined" (when the page tries to reload from the "Next 40 Rows" link) and am hoping there's a simple fix or another way to display the records in Next and Previous pages.
Thanks to anyone in advance for shedding light on this.
- eThank you for the reply, Owain.
Yes - The Next/Previous at the bottom of the page are hyperlinks.
<a href="ThisPage.cfm?start=#Evaluate("start + disp")#">
The following is at the top of the page (and is the variable from the form that I CFOUTPUT in the query):
<cfparam name="ItemNumberDropdown01" default="">
<cfset ItemNumber = #form.ItemNumberDropdown01#>
The error report showed that the "Next Page" hyperlink was reading an undefined variable... although when the "action page" first opens from the form posting to it, it populates the CFSET just fine (per the cfparam and cfset above)... As you mention, the hyperlink clearing the form scope is what causes the error in trying to display the next set of records...
The form page and the 'action page' are both secure pages with an application page setting the session, etc. Am I at risk in using an URL scope?
Where would this URL scope be put? (The href is shown above - would the URL scope go in this? - How would this be written?)
The CFPARAM and CFSET would still exist at the top of the 'action page' and still throw an error wouldn't it or would this be replaced with something else to read the form.variable for this 'first' action page to be displayed?
Thanks again for the 'education' on this...
- ed -
Joining form variables for an insert
I have two form variables #Select# and #masterno1# that I
want to
insert into a single database column with a trailing ".jpg".
What is the correct syntax? I dont have much idea how cold
fusion wants this
variable so it dosent throw an error
Here the value of my insert query. Thanks in advance
<cfqueryparam value='evaluate(#Select##masterno1#".jpg")'
cfsqltype="cf_sql_varchar" maxlength="255">,Perhaps I'm missing something, but haven't you
overcomplicated things?
How about
<cfset newvalue="#Select##masterno1#.jpg">
<cfquery name="myquery" datasource="mydsn">
insert into MY_TABLE
(my_column)
values ('#newvalue#')
</cfquery>
??? -
From Clause query with form variables
forms 9.0.4 rdbms 9.2
Is it possible to create a From Clause query with form variables generated from another block (but in the same form)? I am not having any success.
I searched Metalink. It appears that according to DOC ID # 69884.1, in Forms 6i, this is not possible. Metalink suggest in DOC ID 104771.1 implementating a dynamic From Clause, but when I duplicate the example on my system, I receive an Oracle error. Further investigation from the web form (DISPLAY ERROR) indicates that the system does not see the dynamic value.
Has anyone else run into this error? Has this been fixed in forms 9.0.4 and I am just missing something? Does a dynamic from clause query work? Can anyone point me to an example or post an example or offer any advise.
thanks in advanceAs far as I know it is not possible to use block items in a from clause query in forms 9.0.4. Here is my solution for a From-Clause-Query via the 'Query-Data-Source-Name-Property':
To use the values of the block items in my from clause query I implemented a database package with getter and setter routines for the block item values I needed for the query.
In the Key-Exeqry-Trigger of the From-Clause-Query-Block I set the global package variables with values of the block-items I am interested in. In the From-Clause-Query I used the values in the where-clause via package functions which return the global package variables.
Hope my solution will work for your problem. -
Making a query in Forms 6i to insert values
Hi everyone,
I have 2 Data Blocks in Forms 6i, one is not a Database Data Block and the other one is.
In my first Data Block I have 3 items: teacher_id, grade and class_id
Then, the second Data Block has 10 items where I'm going to be showing 10 rows of data
from my database when the user types the credentials on my 3 items that belongs to my first
Data Block.
Seconda Data Block items:
student_id, student_name,grade_q1,grade_q2,grade_q3
The form should be able to bring just the student_id and the student_name. I have to type then
grade_q1, grade_q2, etc. After that I have to add a buttom to insert all the new information that
I typed to the database.
My question is:
How can I make Forms 6i bring all the data that belongs to that teacher_id, grade and class_id?
After that I would like to insert some data and insert them in the same form.
Can anyone please help me!Hi,
In my first Data Block I have 3 items: teacher_id, grade and class_id This is the non database block right?
Then, the second Data Block has 10 items where I'm going to be showing 10 rows of dataThis is that database block right?
from my database when the user types the credentials on my 3 items that belongs to my first
Data Block.
Seconda Data Block items:
student_id, student_name,grade_q1,grade_q2,grade_q3
The form should be able to bring just the student_id and the student_name.
I have to type then
grade_q1, grade_q2, etc. After that I have to add a buttom to insert all the new information that
I typed to the database.
My question is:
How can I make Forms 6i bring all the data that belongs to that teacher_id, grade and class_id?Does teacher_id and class_id belong to the second data block or in the table on which the second block is based.
If yes In the PRE-QUERY triggers of the second block use :
SET_BLOCK_PROPERTY ('SECOND_BLOCK_NAME', DEFAULT_WHERE, 'TEACHAER_ID = ' || :FIRST_BLOCK_NAME.TEACHER_ID || ' AND
CLASS_ID = ' || :FIRST_BLOCK_NAME.CLASS_ID);Not sure why does first data block have grade, how is it related to query data from second data block.
If you do know then use the grade as required in the DEFAULT_WHERE.
After that I would like to insert some data and insert them in the same form.Now once the block is queried only records matching criteria from first_block will be displayed.
Now User can update the records as required and simply save the records.
Hope this helps.
Best Regards
Arif Khadas -
Trying to move a list of form variables to session variables of the same name
I am trying to move a list of form variables to session variables of the same name and I am having a lot of trouble.
I have never had to post of this forum with a language question in all the 10 years I have been using ColdFusion. I was a qa Engineer @ Allaire/Macromedia back when it was going from one to the other. I have a pretty good grasp of the language.
I have software that runs off a list. The fieldnames are variable and stored off in an array. It's survey software that runs off a "meta file". In this example; I have the number of fields in the survey set to 12 in the "metafile". I have each field declared in that file in array Session.SurveyField[1] and the above loop works fine. I include this "metafile" at the start of the process.
I cfloop around a struct and it works wherever I have needed to use it; such as here - writing to the database for example;
<CFQUERY NAME="InsertRec" DATASOURCE="Survey">
INSERT into #variables.SurveyTableName#
(EntryTime
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
,#Session.SurveyField[arrayindex]#
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,q01_name,q02_AcadTechORNA,q03_Water,q04_FirstAid,q05_CPR,q06_LifeGuard,q07_AED
,q08_ProjAdv,q09_Color,q10_SantaClaus,q11_Supervisor,q12_SupervisorOpinion --->
VALUES
('#EntryTime#'
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thisname = "Session." & Session.SurveyField[arrayindex]>
,'#evaluate(variables.thisname)#'
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,'#Session.q01_name#','#Session.q02_AcadTechORNA#','#Session.q03_Water#','#Session.q04_Fi rstAid#'
,'#Session.q05_CPR#','#Session.q06_LifeGuard#','#Session.q07_AED#','#Session.q08_ProjAdv# ',
,'#Session.q09_Color#','#Session.q10_SantaClaus#','#Session.q11_Supervisor#','#Session.q1 2_SupervisorOpinion#' --->
</CFQUERY>
NOW HERE'S THE PROBLEM: I am running into trouble when trying to move the form variables to session variables of the same name. It is the only part of the software that I still need the datanames hard coded and that is a roadblock for me.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thissessionfield = "Session." & Session.SurveyField[arrayindex]>
<cfset thisformfield = "Form." & Session.SurveyField[arrayindex]>
<cfset #thissessionfield# = #evaluate(thisformfield)#>
</cfloop>
I have tried it with or without the "evaluate"; same result. It doesn't give an error; it just ignores them (session variables look as such in the next page in the chain)
q01_name=
q02_acadtechorna=
q03_water=
q04_firstaid=
q05_cpr=
q06_lifeguard=
q07_aed=
q08_projadv=
q09_color=
q10_santaclaus=
q11_supervisor=
q12_supervisoropinion=
Note: they exist because I CFPARAM them in a loop like the above at the start of the procedure) - and this works just fine!
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset dataname = "Session." & Session.SurveyField[arrayindex]>
<cfparam name="#variables.dataname#" default="">
</cfloop>
</cflock>
I EVEN tried exploiting the Form.Fieldnames list using CFLoop over the list and the same sort of logic within and it still gives me nothing....
Here's the FORM.FIELDNAMES value
"Q01_NAME,Q02_ACADTECHORNA,Q03_WATER,Q04_FIRSTAID,Q05_CPR,Q06_LIFEGUARD,Q07_AED,Q08_PROJAD V,Q09_COLOR,
Q10_SANTACLAUS,Q11_SUPERVISOR,Q12_SUPERVISOROPINION"
Here's the logic; SAME RESULT - The session variables don't get set.
<cfoutput>
<cfloop list="#Form.FieldNames#" index="thisfield">
<!--- <br>#thisfield# --->
<cfscript>
thisSESSIONfield = "Session." & thisfield;
thisFORMfield = "Form." & thisfield;
#thisSESSIONfield# = #thisFORMfield#;
</cfscript>
</cfloop>
</cfoutput>
The CFPARAM in a loop with variable output name works just fine; so does the post (which I included above) as does the SQL Create, Param Form Variables, Param Session Variables, etc.
THIS even works for moving BLANK to each session variable, to zero them all out at the end of the process;
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
</cfscript>
<cfset #thissessionfield# = "">
</cfloop>
</cflock>
Expanding on that code, you would think this would work, but it doesn't;
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
thisformfield = "Form." & thislocalfield;
</cfscript>
<!--- debug --->
<!--- <cfoutput>#thissessionfield# = "#evaluate(thisformfield)#"</cfoutput><br> --->
<cfoutput>
<cfset #thissessionfield# = "#evaluate(thisformfield)#">
</cfoutput>
</cfloop>
And see that debug code in the middle? To add insult to injury... When I uncomment that it shows me this. So it certainly looks like this should work....
Session.q01_name = "Me"
Session.q02_AcadTechORNA = "N/A"
Session.q03_Water = "Yes (certificate expired)"
Session.q04_FirstAid = "Yes (certificate is current)"
Session.q05_CPR = "No"
Session.q06_LifeGuard = "Yes (certificate expired)"
Session.q07_AED = "Yes (certificate expired)"
Session.q08_ProjAdv = "Yes (certificate expired)"
Session.q09_Color = "Gray"
Session.q10_SantaClaus = "Yes"
Session.q11_Supervisor = "Da Boss"
Session.q12_SupervisorOpinion = "Not a bad thing"
There must be some simpler way to do this. This way won't work against all odds even though it seems so much like it should.
So I end up having to hardcode it; still looking for an automated way to set these #@%$*@!## session variables over the list from the form variables of the same @#@!$#%$%# name. Do I sound frustrated???
No matter what I do, if I don't HARDCODE like this;
<cfset Session.q01_name = Form.q01_name>
<cfset Session.q02_AcadTechORNA = Form.q02_AcadTechORNA>
<cfset Session.q03_Water = Form.q03_Water>
<cfset Session.q04_FirstAid = Form.q04_FirstAid>
<cfset Session.q05_CPR = Form.q05_CPR>
<cfset Session.q06_LifeGuard = Form.q06_LifeGuard>
<cfset Session.q07_AED = Form.q07_AED>
<cfset Session.q08_ProjAdv = Form.q08_ProjAdv>
<cfset Session.q09_Color = Form.q09_Color>
<cfset Session.q10_SantaClaus = Form.q10_SantaClaus>
<cfset Session.q11_Supervisor = Form.q11_Supervisor>
<cfset Session.q12_SupervisorOpinion = Form.q12_SupervisorOpinion>
I always get this from my next page because the session variables are empty;
You must answer question 1.
You must answer question 2.
You must answer question 3.
You must answer question 4.
You must answer question 5.
You must answer question 6.
You must answer question 7.
You must answer question 8.
You must answer question 9.
You must answer question 10.
I tried duplicate as well, but I can not get the above to work...
Can anyone help me do this thing that one would think is simple????I think if you use structure array syntax you should get the results you want.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset session[Session.SurveyField[arrayindex]] = Form[Session.SurveyField[arrayindex]]>
</cfloop>
Or probably even easier.
<cfset session = duplicate(form)> -
Using Form Variables in a Formatted Search
Hi everyone, I'm relatively new to SAP B1 and just trying to get some info. I have created a few formatted searches, but I am having trouble with this one in particular.
I am trying to get the 'Business Partner Type' Field under Business Partner Master Data (BP Type, [Form=134 Item=40 Pane=0 Variable=1 OCRD,CardType] to change the user defined fields category displayed [Form=-134 Item=9 Pane=0 Variable=62]
For example, when CardType is Vendor ('S' value), I'd like the user defined fields category 'vendor'( '1' value) to show
Here is my query
SELECT CASE
WHEN $[$40.0.1]='S' THEN '0'
ELSE WHEN $[$40.0.1]='C' THEN '1' END
Which is then assigned as a formatted search to that field.
I was trying to find some sort of definitive guide on form variables and formatted search queries; if anyone can point me in the right direction, I'd appreciate it (I have seen the $[$x.y.z] variables but I am not 100% sure on their usage).
Thanks in advanceHi,
Try this:
SELECT CASE $[OCRD.CardType\]
WHEN 'S' THEN '0'
WHEN 'C' THEN '1'
END
Please also response for your previous open thread. You may just close it if you do not like the answer.
Thanks,
Gordon -
Oracle forms 10g,multiple insert and update problem
Hi,
I have tabular form(4 records displayed) with one datablock(based on a view).
After querying the form could not update all the records but only first record value can select from LOV.
I called a procedure in in-insert and on-update
The query is lik this
PACKAGE BODY MAPPING IS
PROCEDURE INSERT_ROW(EVENT_NAME IN VARCHAR2)
IS
BEGIN
IF (EVENT_NAME = 'ON-INSERT') THEN
INSERT INTO XX_REC_MAPPING
(BRANCH_CODE,COLLECTION_ID,PAY_MODE_ID,RECEIPT_METHOD,CREATED_BY,
CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN)
VALUES
( :XX_REC_MAPPING.OFFICE_CODE,
:XX_REC_MAPPING.COLLECTION_ID,
:XX_REC_MAPPING.PAY_MODE_ID,
:XX_REC_MAPPING.RECEIPT_METHOD,
:XX_REC_MAPPING.CREATED_BY,
:XX_REC_MAPPING.CREATION_DATE,
:XX_REC_MAPPING.LAST_UPDATED_BY,
:XX_REC_MAPPING.LAST_UPDATE_DATE,
:XX_REC_MAPPING.LAST_UPDATE_LOGIN);
ELSIF (EVENT_NAME = 'ON-UPDATE') THEN
UPDATE XX_REC_MAPPING
SET BRANCH_CODE=:XX_REC_MAPPING.OFFICE_CODE,
COLLECTION_ID=:XX_REC_MAPPING.COLLECTION_ID,
PAY_MODE_ID=:XX_REC_MAPPING.PAY_MODE_ID,
RECEIPT_METHOD=:XX_REC_MAPPING.RECEIPT_METHOD,
LAST_UPDATED_BY=:XX_REC_MAPPING.LAST_UPDATED_BY,
LAST_UPDATE_DATE=:XX_REC_MAPPING.LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN=:XX_REC_MAPPING.LAST_UPDATE_LOGIN
WHERE ROWID=:XX_REC_MAPPING.ROW_ID;
END IF;
END INSERT_ROW;
END MAPPING;
Whether the table gets looked or sholud i use some other trigger or loops ?
someone suggest me how to edit this query for multiple update.
Thanks
sat33I called a procedure in in-insert and on-updateWhy are you writing this code in the first place? If you have a block based on an updatable view, just let Forms do the inserts and updates.
If it's not an updatable view, use instead of triggers on the view.
See this current thread too:
INSTEAD of Trigger View for an Oracle EBS New form development -
Form Variables Don't Pass for Some Clients
Recently, I’ve noticed some problems on one of my pages
where form field variables aren’t passing to my action page.
As far as I can tell, this is a new problem.
This is the error I’m getting:
Error resolving parameter FORM.EMAIL
The specified form field cannot be found. This problem is
very likely due to the fact that you have misspelled the form field
name.
The error is thrown when a cfquery is unable to find the form
variable.
The query looks, basically, like this:
<cfquery name="Iogin" datasource="dsn">
SELECT Count(*) AS Match
FROM Users
WHERE users.email = '#FORM.email#'
AND users.password = '#FORM.password#';
</cfquery>
I know I could squash these errors with a cfparam or with
other error checking, but what I’m really concerned about is
why the form variables aren’t there. I have tested the form
on a number of my internal clients and have not been able to
replicate the error as it is being triggered from outside clients.
I am able to submit a blank form or a complete form without any
errors being thrown. I have established that the form submissions
are coming from my site and are not being submitted by an outside
domain.
QUESTIONS:
1. Does anyone know what might be happening to cause the form
variable to disappear? Shouldn’t all the forms variables be
submitted when a user hits the submit button, regardless of whether
there is data in the form field?
2. Could a firewall on the clients’ end be withholding
the form variables without notifying the user?
3. Have there been any recent changes to browsers that could
be holding back form variables?
Any help would be greatly appreciated!@Azadi
quote:
from your posts it looks like this happens to different forms
in your application (you mentioned the email field and also a
select box, which is presumably in some other form)
I was able to resolve the problem with the second form (the
one with the select box, not the one posted above). A JavaScript
resided on that action page which triggers a service. The service
(similar to GoogleAds) receives the page’s url from the
JavaScript and then the service comes back and loads the page to
evaluate the page’s content. The result: Action pages being
loaded with no form content. My error reporting, very similar to
what insuractive suggested, helped solve this problem.
HOWEVER, we still periodically have trouble with the other
form. I know from speaking with at least two users that the problem
is a direct result of users following the planned application
flow—form to action page. So this discussion is still
relevant.
@insuractive
quote:
you should make sure you test to see what happens when the
client has javascript and/or cookies disabled on their browser.
This is a good thought. I’m embarrassed to say that I
haven’t tried accessing this form with cookies and JavaScript
turned off. I will try this and report back.
Thanks to all of you who are offering suggestions. -
Want to pass Applet form variables without showing it on URL Location
I am running one applet with some form variables. After submit I want to pass those to .asp file to store into database.
If I use URL method then all are getting displayed on URL location of browser which I do not want. I want to pass many form variables to another .asp file, so it may not be good also.
What is the best way of doing it ? Need urgent help about it.I tried following code using URL Connection Object, Code is running fine in IE and Appletviewer, but not running in Netscape.
Following is the code:
There is an applet with form. After Submit button, The form variables will be send to ASP script where I am storing it into database. In Netscape the server connection is made (blank record is getting created) but data is not passed.
public void actionPerformed(ActionEvent event) {
try{
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(512);
PrintWriter out = new PrintWriter(byteStream, true);
String postData = "firstName=manisha";
out.print(postData);
out.flush();
URL dataURL = new URL("http://manisha/appletexamples/confirm-px.asp");
URLConnection connection = dataURL.openConnection();
connection.setUseCaches(false);
connection.setDoOutput(true);
String lengthString = String.valueOf(byteStream.size());
connection.setRequestProperty ("Content-Length", lengthString);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
byteStream.writeTo(connection.getOutputStream());
BufferedReader in =
new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while((line = in.readLine()) != null) {
System.out.println("line: " + line);
} //while
in.close();
} //try
catch(Exception e){}//catch
}//action performed
My ASP Code
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open("DATABASE=phptestdb;DSN=phptestdsn")
%>
<HTML>
<HEAD>
<TITLE> A Sample Program </TITLE>
</HEAD>
<BODY>
<%DIM fname
fname = ""
fname = Request("firstName")
response.write ("fname : " & fname)
qrystr1 = "insert into applettesttable (fname) values ('" & fname & "')"
conn.Execute qrystr1
conn.Close
Set conn = Nothing
%>
</BODY>
</HTML> -
Referencing "Form Variables" in Formcalc
WIth LiveCycle Designer ES4 I'm trying to place a group of string variables used throughout my form so as not to have to edit the same variables in several places.
I don't want to use Form Properties>Variables because one can't see the entire group at once. In other words, there are variables that need to be located next to subordinate variables for a clearer picture and to prevent errors, i.e. var propertyOwner, var propertyTract, var propertyTelephone.
Under variables in the form hierarchy, I inserted a "Script Object" folder and named it "Owners". In that folder I entered all of the mentioned variables. The folder/object name is "TwentyTwoHills.#variables[0].Owners". The first variable is
var TTHOwner1 = "Joe Smith";
How can I reference this variable to be used to load a drop down box in my form with FormCalc?
Any help appreciated,
Thanks,
FredHi,
in script objects you only can use JavaScript syntax, FormCalc in not supported by these objects at all.
As you also cannot call an JavaScript action from a FormCalc event.
You'll have to use JavaScript in all scenarios you're using the script objects.
Here's a sample how to do this.
Create a function in your script object, that contains some nested arrays.
Each array contains two values, the first represents the name the second the value.
Through the forEach method you can simply filter the arrays.
function loadValue (vValue){
var aVars = [
["varA", "Lorem"],
["varB", "Ipsum"],
["varC", "Dolor"]
vReturn;
aVars.forEach(function (element, index) {
if (element[0] == vValue) {
vReturn = element[1];
return vReturn;
Retrieve the value from array "varA" use this function.
Owners.loadValue ("varA"); -
HI~
I have a cfform on my index.cfm page, and the action is set
to go to a confirm.cfm page. On that page, I want the user to be
able to look at the information they entered into the form, and
then hit "Submit" if it is correct. Right now, I am able to display
the form information on the confirm.cfm page, but I'm having a hard
time with my insert statement. Right now, when I hit the final
Submit button, an entry is made in the database, but none of the
variables are passed. I'm guessing this is because of the cfparam
default="" setting, but I don't know what else to set it as-- if I
try to set it as semester or form.semester, it says it is not
defined. Please help! Thanks!semi star gazer wrote:
> OK, I think I'm still missing something here. This is
what I have right now.
> With this code, I get a blank entry in the database when
the user hits the
> Submit button.
>
> <cfparam name="form.semester" default="">
>
> <cfif isDefined("form.submitEval")>
>
> <!--- insert form data into database --->
> <cfquery name="insertEval" datasource="intern">
> INSERT INTO mentorEvals (
> semester
> ) VALUES (
> '#Trim(form.semester)#'
> )
> </cfquery>
>
> <cfform action="#CGI.SCRIPT_NAME#" name="submitEval"
METHOD="post">
> <cfinput type="hidden" name="semester"
value="form.semester">
> <!--- Submit Button that reads "Submit Evaluation"
--->
> <cfinput type="submit" value="Submit Evaluation"
name="submitEval"
> id="submitEval">
> </cfform>
>
try using <input type="hidden" ...> instead of
<cfinput ...> - i seem to
recall there being issues with hidden cfinput fields...
also - where's your closing </cfif>??? it should be
after </cfquery> - i
hope it is actually there...
just to make sure semester is passed from first form, you can
put
<cfoutput>#form.semester#</cfoutput> right after
your <cfparam>
NOTE: you do not really need that <cfparam> there... it
does not do
anything... unless you are planning to use it later for
validation
routines... i wonder if it may be tampering with the semester
value...
it shouldn't, but who knows...
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
Passing FORM variables through CFSET
I am writing an account creation page for my site. After the
user inputs the required information, I would like to 1. confirm
that their email is not a duplicate of another user 2. Pass them
off to another page that allows them to confirm the information
that they input and submit the info to the database. I would like
to have the email confirmed on that page through passing the
FORM.email variable to the #CGI.SCRIPT_NAME#. If the RecordCount on
the query for duplicate email addresses comes back VALUE=0, use
CFLOCATION to pass to the next page with the FORM variables intact.
However, as forms can only have one action attribute, what is the
best way to do this, in your opinion?
Thanks so much for your help!
danuse session var to store form data:
- user submits form.
- form posts to same page (to itself).
- check for duplicate email
- if no duplicate found, copy form to a sesion var and
cflocate to next
page; if duplicate found show error to user
- on next page display user-submitted data from the session
var
make sure session vars are enabled in cf administrator and
sessionmanagement is enabled in your appliction.cfm/cfc
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/ -
Lightwindow passing form variable to action page
Hi,
I have a form that is popup using lightwindow to allow users to fill out the form. For some reason, I couldn't get the form.variables to pass to the action page and insert into a database. Anyone has suggestions or ideas?
thanks.link to open lightwindow pop up page. of course i've all the js required on the top of the page
<a href="form.cfm" params="lightwindow_width=500,lightwindow_height=600" class="lightwindow page-options">Form</a>
here is the form
<form id="form1" name="form1" method="post">
<p><label for="fname">First Name</label><input type="text" name="fname" id="fname" class="inputText" /></p>
<p><label for="lname">LastName</label><input type="text" name="lname" id="lname" class="inputText" /></p>
<p><p><a href="hello.cfm" params="lightwindow_form=form1" class="lightwindow_action" rel="submitForm"><button>Submit</button></a> or <a href="#" class="lightwindow_action" style="color: blue;" rel="deactivate">Cancel</a>
</p>
here is the action page for the form (hello.cfm)
<cfoutput>#form.fname# | #form.lname#</cfoutput>
I do not know if this is out it's supposed to do it or not but the form variables are not passing over to the action page.
thanks -
Bizarre CFIF issue with dynamic form variables? Very strange...
I can't figure out what I'm doing wrong here. Here's my code. Issue explained below.
<cfquery name="reviewconfigloader" datasource="MOLMS">
SELECT *
FROM dbo.BaseModel
WHERE dbo.BaseModel.AccountID = #molmsAccountID# AND.dbo.BaseModel.basemodelActive = 1
</cfquery>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<cfloop query="reviewconfigloader"><cfif isdefined("form.baseconfig#reviewconfigloader.basemodelID#") AND ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ "" AND ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ 0><cfoutput><tr>
<td width="40%" bgcolor="##F7F7F7" class="basemodelsub"> #form['baseconfig#reviewconfigloader.basemodelID#']# #reviewconfigloader.basemodelName# #reviewconfigloader.basemodelSubName#</td>
<td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">x 14 </div></td>
<td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$486/yr</div></td>
<td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$1444/yr</div></td>
<td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$1444/3 yr</div></td>
</tr></cfoutput></cfif></cfloop>
</table>
What I'm doing here is fairly basic.I'm running a query with a number of configs in it...and then creating a loop to output them. Ultimately, I only want the configurations that didnt have 0 submitted in the form on the previous page. Each one of the configs in the config query has a dynamic form variable on the previous page with a quantity tied to it. I am trying to eliminate all quantities past that aren't 0 (or not eliminate, just not show)...as you can see from the cfif statement.
Here's where it gets weird. You'll notice I output #form['baseconfig#reviewconfigloader.basemodelID#']#, just for testing, which shows me the quantity as it should. I ran a test and put in a couple of 1s, 0s, 12s, 6s, etc in the form fields on the previous page. If this thing worked, it wouldnt show anything for any of the records with their basemodelID value being submitted as 0. Not the case. It shows all records. What is more hilarious is that it outputs perfectly in my test #form['baseconfig#reviewconfigloader.basemodelID#']#, showing the correct numbers entered in the previous form, the 1s, the 0s, etc, tied to each record. But for whatever reason, the cfif code isn't catching it.
What's even more bizarre...I replaced the cfif ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ 0 with GT 12 (12 was the highest number that I put in the form) and it still showed all records. Then I put it in as LT 12 and it showed nothing. I decided to take it one step further and put it in for GT 1231243242343 (random massive number), which it still showed all of the records. So somehow, my CFIF statement thinks that ("form.baseconfig#reviewconfigloader.basemodelID#") is a incredibly large number, although when I output it in the row below, it is the number it should be.
I'm stumped. Any ideas? Thanks in advance!!Hey Dan...thanks....unfortunately...with the cfif testing, thats kinda what I'm
doing because I dont have an "expected" value. My expected value is anything a user inputs thats greater than zero, hence NEQ 0 and NEQ "". The real problem is taht what I'm outputting works and what the cfif clause is seeing is obviously very different.
As far as your comment about looping out the variables and then setting a query equal to the value in a cfquery, remember...these are form objects and therefore nothing can be tied back to the database. The result from the code is establishing a form variable (example.... form.basemodel1 (if 1 was the basemodelID from the database query) so it can capture whatever data the user has passed from the previous page in a text input. So that input could have been 23, it could have been 1053.
So really the only way to do it is create a query and loop out the variables.... and attach them to form objects (basemodel1, basemodel2, basemodel3 etc where the 1,2 and 3 are the unique ID's for those models in the database), and then look for where those form objects may have been filled in in the previous page by stating IF this form object not equal to 0 or "", output the data.
Does that make sense? Thanks for the help guys I'm completely stumped by this. I've done this a million times with CFIF and I'm really struggling with why this isnt working....
JE
Maybe you are looking for
-
How do I play a video in full-screen mode on one screen of a dual-screen Windows 7 system without blanking out the other screen? Not losing the other screen would be useful as I would like to, for example, monitor my emails whilst watching a video o
-
One of my databases is "stuck" in referral mode. When I set it through the console to accept reads and writes a few minutes later it reverts back to referral mode. Her is the message from the error log: [13/Apr/2005:10:10:09 -0400] - WARNING<10265> -
-
How the getNetworkInterfaces() of NetworkInterface class works
Hi, I would like to know how the method getNetworkInterfaces() method in the NetworkInterface class works. Sometimes I get a cached data on the interfaces, sometimes I get an empty Enumeration getting returned. Does this method not get the refreshed
-
Group Policy - Workstation Group
Hello, I am trying to apply a windows group policy using a workstation policy package and associating it with a workstation group. When I go log in to a workstation that is a member of the workstation group after the policy has been setup and go into
-
Assessment Cycle Receiver Group
Hi, I have created Product Group in Receiver Tab in CO-PA Assessment Cycle. Here I want to automatically add Products to Product Group whenever new products are introduced as the volume of creating new products are more. Pls suggest