Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with dynamic variable

Status
Not open for further replies.

jokerparis

Programmer
Jul 7, 2000
15
0
0
FR
i have create a form like this :<br><br>&lt;cfoutput&gt;<br>&lt;cfform action=&quot;ajout.cfm?val=#Nb_Sonda#&quot; method=&quot;POST&quot;&gt;<br>&lt;CFLOOP CONDITION=&quot;i LESS THAN OR EQUAL TO Nb_Sonda&quot;&gt;<br>Saisissez la réponse numéro #i# :<br>&lt;br&gt;&lt;input type=&quot;text&quot; ID= ToString(&quot;champ&quot; & #i#)&gt;&lt;br&gt;<br>&lt;CFSET i=i + 1&gt; <br>&lt;/cfloop&gt;<br>&lt;br&gt;<br>&lt;input type=&quot;Submit&quot; value=&quot;Validez Sondage&quot;&gt;<br>&lt;/cfform&gt;<br>&lt;/cfoutput&gt;<br><br>where nb_sonda is a value passed by a precedent form, to create dynamic fields<br><br>next i want to store that in database :<br><br>&lt;cfquery name=&quot;num&quot; datasource=&quot;essai&quot;&gt;<br>select max(Id_Sonda) as NumSonda<br>from sondage<br>&lt;/cfquery&gt;<br><br>&lt;cfset j = '1'&gt;<br>&lt;cfoutput&gt;<br>&lt;CFLOOP CONDITION=&quot;j LESS THAN OR EQUAL TO Val&quot;&gt; <br>&lt;cfset envoi = document.forms(tostring(&quot;champ&quot; & #j#))&gt;<br>&lt;cfquery name=&quot;rep_sond&quot; datasource=&quot;essai&quot;&gt;<br>insert into question_sondage(Id_Sonda , Lib_Quest_Sonda , Compt_Quest_Sonda)<br>values ('#num.NumSonda#' , '#envoi#'&nbsp;&nbsp;, '0')<br>&lt;/cfquery&gt;<br>&lt;CFSET j=j + 1&gt; <br>&lt;/cfloop&gt;<br>&lt;/cfoutput&gt;<br><br><br>I don't arrive to use the value&nbsp;&nbsp;of the fields in the other forms.
 
put your val=#Nb_Sonda#&quot; in a hidden field something like:<br>&lt;input type=&quot;hidden&quot; name=&quot;val&quot; value=&quot;#Nb_Sonda#&quot;&gt;<br>works for me<br>marc
 
ok, it's another way to pass a var from page to another , but my matter is i can't store in my database the values of the fields create dynamically with the loop.<br>thanks for your help..
 
Jocker,<br><br>Let's take it from the top.&nbsp;&nbsp;You need 3 pages to do all this.&nbsp;&nbsp;Suppose that:<br>*&nbsp;&nbsp;the page which supplies the value of Nb_Sonda is page1.cfm<br>*&nbsp;&nbsp;the page with the form is page2.cfm<br>*&nbsp;&nbsp;the page which updates the DB is page3.cfm<br><br>Page1.cfm has to pass the value of Nb_Sonda to page2.cfm<br>There are several ways of doing this in page1.cfm<br>The simplest is &lt;cflocation url=&quot;page2.cfm?Nb_Sonda=#value#&quot;&gt;<br>In this case page2.cfm has to refer to this value as #URL.Nb_Sonda&quot; and the form in page2.cfm has to say<br>&lt;cfform action=&quot;page3.cfm method=&quot;POST&quot;&gt;<br><br>As tvpittner says, a hidden field in the form is the easiest way of passing the value from page2.cfm to page3.cfm<br>Then page3.cfm has to refer to it as #URL.hidden_field_name#<br>in the update query<br><br>If you need any more help, it might be useful to give a description of what you're trying to do (a specification) as well as the code.<br><br><br>
 
Ok but my matter is not in the passing of this var, the var who i don't arrive to passe is them from the new fields<br><br>it's for a survey<br><br>one <br>-i say the title, the question and the number of possible response and record this in a table survey<br><br>two in a new page i complete the fields create by a loop, who loop until the number is equal to Nb_sonda<br><br>three i want to store the different response but i don't arrive, with this code it store the name of the field and not the value in the field<br><br>does exit a way to specify FORM.INPUT ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top