Populate and Update Form data in ColdFusion - forms

I have a form the needs to be populated and and updated. There are several dropdown fields and input fields on the form that need to be populated and then allow the user to make a change if necessary. I have created queries to select the data, then I want to populate the form with the selected data but, allow a user to change the form fields. I have tried with the first field which is a dropdown field but, I receive an error saying that I can't nest two queries.
This is the error I received: A query driven cfoutput tag is nested inside a cfoutput tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.
Here is my code:
<cfoutput query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfoutput>
Here is my getinfo query:
<cfquery name="getinfo" datasource="dbotest">
SELECT ProgramName, TestName
FROM Programs
WHERE ProgramID = "D219"
</cfquery>

What you've posted is valid syntax for outputting a query.
<cfoutput query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfoutput>
If your page is set up like this, then that is invalid. You can simply change <cfoutput query="getinfo"> to be <cfloop query="getinfo">
<cfoutput>
<!--- other code --->
<cfloop query="getinfo">
<select name="ProgramName" id="ProgramName" style= "font-size:24px">
<option style="font-size:24px" value = "0">--Program Name--</option>
<cfloop query="PName">
<option value="#ProgramName#">#ProgramName#</option>
</cfloop>
</select>
</cfloop>
<!--- more code --->
</cfoutput>
(I know this isn't really an answer but should hopefully help clear things up.)

Related

I want to have a select and input field in react with all the options in my JSON file or mongodb database

I have to provide a dropdown in my form with a large number of options in it but the selected options are to be shown at various places so i have to store the selected option or its id at database too.
<FormGroup>
<Label htmlFor="category">Category</Label>
<select innerRef={input => (this.category = input)} id="select" class="form-control" >
<option value="0">Please select</option>
<option value="1">Mobiles</option>
<option value="2">Television</option>
<option value="3">Washing Machines</option>
</select>
</FormGroup>
This is the gist of the form type i want, there will be other categories in somewhere around 25. I cant have 25 options opening in dropdown. I want to have something like select and input type in dropdown. Also i want to store the option selected by the user and then display it somewhere else.

AutoHotKey: How to get list of available values from drop down list?

I am trying to automate a website to get data. Usually if I know in advance what are the possible value from the drop down list, I can hard code them in my script.
But if I don't know what are the values, is there an elegant way to dynamically obtain the drop down list values?
Working sample from: https://autohotkey.com/boards/viewtopic.php?t=15574
select name="ConnectDTO.EvaluationGroupId" id="ConnectDTO_EvaluationGroupId" style="width: 260px;" required="yes" data-val-number="The field Evaluation Group must be a number." data-val="true"><option value="">Please Select</option>
<option value="4">ccpdmanagement</option>
<option value="7">AM Northern</option>
<option selected="selected" value="3">cwplanning</option>
<option value="1">mnplanning</option>
<option value="2">msplanning</option>
<option value="9">LCC</option>
<option value="6">powerquality2</option>
<option value="8">AM Southern</option>
<option value="5">tcoqueries</option>
</select>
When my script arrived on the page after loadIE(wb), is there a way to "get" the list of selection - such as ccpdmanagement, AM Northern etc...?
I know how to select them once the option is known in advance only.
pwb.document.getElementById("ConnectDTO_EvaluationGroupId").Focus()
pwb.Document.GetelementById("ConnectDTO_EvaluationGroupId").value := "1"
Thanks.
I found a solution here: https://autohotkey.com/boards/viewtopic.php?t=35467
Althought the Author stated he has a problem with the code (stated not work for some reason).
But for my purpose - to retrieve the list of all the drop down list option. It worked fine.
myDropDownList := wb.document.getElementById("your_dropdown_ID")
loop % myDropDownList.length
{
test := myDropDownList[A_Index-1].value
MsgBox %test%
}

AJAX Adjust part of zend form based on select

I have a (Zend) form like this.
<form>
<select id=”select1”>
<option value=”1”>choice 1</option>
<option value=”2”>choice 2</option>
</select>
<div id=”adjust”>
<input type=”text” value=”choise3”></input>
<input type=”text” value=”choise4”></input>
</div>
</form>
When a user makes a choice in #select1 I want to replace te form fields in div #adjust with fields I construct from a query from a database (or a few partial forms). So the fields can be replaced by totally other fields and also more or less fields.
Replacing is no problem with eg. Jquery. But when they are filled, how does Zend form process them in a correct way (because I didn’t define the fields in the form). And when there are fields not passing the validators, how do they get back then with fault announcements

How to set custom data attbributes with zend form select?

I am using Zend_Form_Element_Select to create a select form element. Here's how the inner HTML is rendered:
<option value="9" label="Biscuits">Biscuits</option>
<option value="10" label="Scones">Scones</option>
<option value="11" label="Cakes">Cakes</option>
Now, I want to be able to include a custom data attribute, data-qty, with each option, per the following example:
<option value="9" label="Biscuits" data-qty="27">Biscuits</option>
<option value="10" label="Scones" data-qty="12">Scones</option>
<option value="11" label="Cakes" data-qty="21">Cakes</option>
I can't see any way to do this out of the box so I think I'll need to extend the select element, create a new decorator, or some such solution. Any ideas?

Zend_Form and Decorator help

<select name="day" id="day">
<option value="0" label="Day:">Day:</option>
<option value="1" label="1">1</option>
</select>
<select name="month" id="month">
<option value="0" label="Month:">Month:</option>
<option value="1" label="January">January</option>
</select>
<select name="year" id="year">
<option value="2010" label="2010">2010</option>
</select>
Can I build a form part like this format using Zend_Form and Decorator? I have read many posting but couldn't find any which helps to pack more than one elements together inside a "dd" tag. Does it possible or not?
http://weierophinney.net/matthew/archives/217-Creating-composite-elements.html
This post goes onto explain how to create a composite object using Zend_Form_element and settings up custom decorators.
It is also built around having all date fields grouped together so you could probably just modify this example to get what you want.