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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing input form data or refreshing form.

Status
Not open for further replies.

omerdurdu

Programmer
Jul 21, 2001
72
TR
I have a from includes like 50 input boxes. 46 th input box shows the Contact information and it is a select box. And there is a button next to this select box and it says Add New Contact. when I click that a pop up window comes up and asks contact name and contact information. The question is:
The user fills out all input boxes until 46th one and his name is not in the contact select list. He wants to add one and he clicks Add New Contact button. He fills out contact info forum and insert the info into database. What I would like to do how can I refresh that input form page. Because new contact is not into select list and I dont wanna to users loose the data they already entered into other 46 input boxes.
Thanks
 
sorry, my contact list dynamic it is coming from a query.
 
Wwebspider can you explain on this more: If you check my code structure up there I followed your idea: I added
<cfparam> into my main form.
and I added in my input value=<cfoutput>#form.Fieldname#&quot;
right now where am i gonna add that onSubmit event
and what will be the syntax.
I appreciate it
Thanks for your help
 
- when user clicks on the submit button, setAction() function is called (JavaScript, client side); function will check the newOption form field and if it's not blank will assign value &quot;addOption&quot; to the form &quot;a(ction)&quot; field;
the form is submitted; on the server, cf is checking if the form.a field is defined at all; if yes, it means that the request is comming from the page with the form on it; next, cf will check if the form field &quot;a&quot; has the value &quot;addOption&quot;; if yes, the only action is to add new record and execute new query; this is enclosed within the cftransaction tags so the second query will wait for the first to be executed in full; after that, the page is sent to the client with new query so the option box will be populated with new data; all other form fields remain same;
however, if the form.a field has the value &quot;submitFrm&quot;, the form is complete and you can execute whatever code there and send user to another location;





<cfparam name=&quot;field_1&quot; default=&quot;&quot;>
<cfparam name=&quot;field_2&quot; default=&quot;&quot;>
.
.
.
<cfparam name=&quot;field_45&quot; default=&quot;&quot;>


<cfquery name=&quot;customers&quot; datasource=&quot;dbn&quot;>
SELECT firstName FROM Customers;
</cfquery>


<cfif IsDefined(&quot;form.a&quot;)>

<cfif form.a EQ &quot;addOption&quot;>
<cftransaction>
<cfquery name=&quot;customers&quot; datasource=&quot;dbn&quot;>
INSERT INTO Customers (firstName)
VALUES ('#form.firstName#');
</cfquery>
<cfquery name=&quot;customers&quot; datasource=&quot;dbn&quot;>
SELECT firstName FROM Customers;
</cfquery>
</cftransaction>
<cfelseif form.a EQ &quot;submitFrm&quot;>
<!--- code to process the form in full... --->
</cfif>
</cfif>




<script>
function setAction() {
var frm = window.document.mainFrm;
if (frm.newOption.value != '') {
frm.a.value = 'addOption';
}else{
frm.a.value = 'submitFrm';
}
}
</script>

<form action=&quot;<cfoutput>#cgi.Script_Name#?#client.URLToken#</cfoutput>&quot; method=&quot;post&quot; name=&quot;mainFrm&quot;>
<input name=&quot;a&quot; type=&quot;hidden&quot; value=&quot;&quot;>


<input name=&quot;field_1&quot; type=&quot;hidden&quot; value=&quot;<cfoutput>#form.field_1#</cfoutput>&quot;>
<input name=&quot;field_2&quot; type=&quot;hidden&quot; value=&quot;<cfoutput>#form.field_2#</cfoutput>&quot;>
.
.
.
<input name=&quot;field_45&quot; type=&quot;hidden&quot; value=&quot;<cfoutput>#form.field_45#</cfoutput>&quot;>

<select name=&quot;fourtySixthField&quot;>
<cfloop query=&quot;customers&quot;>
<option><cfoutput>#firstName#</cfoutput></option>
</cfloop>
</select>

<input name=&quot;newOption&quot; type=&quot;text&quot;>

<input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;JavaScript:setAction();&quot; class=&quot;submitButton&quot; id=&quot;submitButton&quot;>

</form> Sylvano
dsylvano@hotmail.com
 
Thanks for the code WWebSpider.
Is this code will be in my main form or in the popup contact form.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top