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
 
here is one way you can do this:

- on the page with 50 inputs, for every field use the ...value=&quot;#form.fieldName#&quot;... attribute; to avoid the error you will have to define those fields; you can use <cfparam name=&quot;form.fieldName&quot; default=&quot;&quot;> tag to do that;

- when user opens new window to add new contact and submits that form, the database is updated; here you can use on submit event to refresh opener window (window with the main form);

- the new contact should be added to the selection box and the form should be filled as all the form variables are defined this time and cfparam won't define the fields Sylvano
dsylvano@hotmail.com
 
thanks for your reply.
I would like to give you more info about what i am doing:
I have an input form. the user starts fill out the form, when he comes 46th input box, which is a contact list box, he would like to put his name in that list box. he clicks a button &quot;Add new contact&quot; and he goes to other input form page and fills out contact input form and he clicks insert, adds his name into list box. but what i wold like to do when he clicks insert button he will go back to the main input form and and choose his name from list box and continue fill out the form (the rest of them).

I followed your instructions: I defined the parameter and I added for each input box value=#form.fieldName# such as:

<cfparam name=&quot;metadata&quot; default=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;metadata&quot; value=&quot;#form.metadata#&quot;>

but the problem is: when i add value=&quot;#form.metadata#>,
in my input box this words shows up.
Seem the value of input box is value=&quot;#form.metadata#&quot;

can you give me more info about this. I appreciate it for your help.



 
try this:
<cfparam name=&quot;form.metadata&quot; default=&quot;&quot;>

<input type=&quot;text&quot; name=&quot;metadata&quot; value=&quot;<cfoutput>#form.metadata#</cfoutput>&quot;> Sylvano
dsylvano@hotmail.com
 
Can you give me some information about &quot;onSubmit&quot; event
how can I call the my main input page when i click the insert button on my secondary input form (contact form)
Here is the my main input form:
<form action=&quot;insertnew.cfm&quot; name=&quot;frm&quot; method=&quot;post&quot; onSubmit=&quot;return validateForm()&quot;>
(this onSubmit I am using is checking validating data in input from). Can I use second input form or do i have to put that onSubmit form somewhere else.
Thanks
 
Following what WWebSpider explained, you don't have to validate the opener form now since the data you submit from there will all be rewrite into the page as is. To do that, in your new window, on your submit button action, add opener.[formname].onsubmit=new Function(&quot;&quot;);opener.[formname].submit();

Another way to do it is to add a method into your opener page called addOption(text,value) or something like that which is used to add an element into your select element. Just call it by using opener.addOption([your display text],[the value to link])

I think that the new window will keep it's ID even if you change it's location so you could define this script in the returned page.
 
On my new window, i did this. Is this the correct syntax:

<cfform action=&quot;contactinsert1.cfm&quot; method=&quot;post&quot;>
-----
-----
---
---
<input type=&quot;submit&quot; value=&quot;Insert&quot;
opener.[formname].onsubmit=new Function(&quot;&quot;);opener.[formname].submit();>

Can you tell me where am I gonna put that syntax:
Thanks
 
I've never worked with the CFForm tag so I don'T know all of its syntax but I guess there's a ONSUBMIT parameter. you could either but it there or in the ONCLICK of the submit button.
[formname] is the name of your form on your main page.
The reason for opener.[formname].onsubmit=new Function(&quot;&quot;); is to bypass the validation function. You will also have to add an element to be able to know that it's not a real post but only a refresh so that your form is not processed on the server.
 
I am sorry but it seems it didnt work. Here is what I did
I have two forms. One is data entry form the other is contact form.
In data entry form there is a button &quot;Add New Contact&quot;
when I click there i am going to contact form. What I would like to do I fill out the contact form and then when I click insert button in the contact from I would like to go back the data entry from and continue fill out the form. I would like to save what i entered before: here is the what I am doing:

Data Entery form:

<cfparam name=&quot;form.Accuracy_Data&quot; default=&quot;&quot;>
<cfparam name=&quot;form.Date&quot; default=&quot;&quot;>
<cfparam name=&quot;form.Metadata&quot; default=&quot;&quot;>

<form action=&quot;insertnew.cfm&quot; name=&quot;frm&quot; method=&quot;post&quot;>
----
---
---
---
---
--
&quot;Add New Contact&quot;
--
--
--
<input type=&quot;submit&quot; value=&quot;insert>
</form>

Add New contact form:

<cfform action=contactinsert1.cfm&quot; method=&quot;post&quot;
onSubmit=&quot;opener.[frm].onsubmit=new function(&quot;&quot;);opener.[frm].submit();
----
----
-----
---
---
<input type=&quot;submit&quot; value=&quot;insert&quot;>
</form>

Thanks for help
</ccform>




 
From what I got here, the problem is that you left the [] around your form name. In fact, there's 2 ways to obtain a reference to an object in the DOM.

First one: parent.child.attribute
Second: parent[child].attribute
In a many levels statement, you could mix both:
document[form].field.attribute

But never would document.[form] work.

A problem you could get using this method is that the opener page is processed before your new contact is added to the DB... Bad thing... What you could do is to submit the opener window when the new window get the result... But still that the addOption method is faster because you get less trafic and less server work.

Take a look here:
 
Can you show me that in my code?
Becasue I am not sure about the syntax still.
Thanks
 
Can you show me that in my code
I am not sure about the syntax
where do you want me to use your syntax
in <input> or in <from>
Thanks
 
I mean one fo the method.
Please show that in my code.
I appreciate it
 
What I understand you're doing now is that when a usert click insert on your form, the contact is directly added to the DB (you don't wait for the other form to be submitted. So after the contactinsert1.cfm (by the way, you'Re missing a &quot; before contactinsert1.cfm) is processed, you display a page on which the only code is something like:
Code:
<CFOutput>
<SCRIPT>
  opener.frm.addOption(#ContactName#, #ContactID#)
  window.close()
</SCRIPT>
</CFOutput>
In the opener, you would add the function
Code:
<SCRIPT>
    function addOption(sText, sValue)
    {
	oOption = document.createElement(&quot;OPTION&quot;)
	oOption.text=sText
	oOption.value=sValue
	window.document.forms['frm']['selectName'].options.add(oOption,0) //Where selectName is the name of your contact container and 0 is the position at which you want to add the new option
	document.frm.selectName.options[0].selected=true //This is to select the added option (change 0 to whatever index you chose)
    }

Like you'Re seing, I was a little wrong in one of my last messages as the referencing of the object is not
document[formName][FieldName]
but
document.forms[formname][fieldName]

This is supposed to work...
 
I think I coulnt explain to you what i am doing
thanks anyway
 
No we are talking on different subjects:

If you check my code you can understand what i am doing.
Let me explain again:
The main subject is here refreshing an input form.
I have an input form. It has 50 input box. 46 th input box is a select box, contains names. if i dont have my name in that select box, there is a button there and when I click that button a popup window is coming up. this is a contact form. what i would like to do I will fill out that contact form and when I click insert button I would like to see the new name in the contact list in main input form. Or do you have any idea how to do that. It doesnt matter this way or other way.
Thanks
 
i am gonna bug in again:

omerdurdu, as you know, the coldfusion involves server side programming while the form is being filled in on the client side; with that in mind here is the approach you should take:

- user is filling the form fields 1 - 45;
- when the 46th field if filled up, the form have to be submitted to the cf server so you can add new input to the database; nothing else is done on this trip, just add new name and refresh the query with the contacts; do not use the cflocation tags as if you do the form variables will lose their scope and will not be available any more;
- the same page with the form fields is being sent to the user but this time form variables are defined so the cfparam tags you have used to define those will be ignored this time;
- form fileds 1-45 are displayed and form variables are used for its values;
- when 46th field (the option box) is populated, use the new query with the updated contacts - the new contact should be displayed and ready for selection (do you know how to dinamically populate an option box?);

BKQc is doing the same thing using JavaScript on the client side; this is the server side and it is basically up to you to decide which approach are you going to take;
both have its ups and downs;

good luck
Sylvano
dsylvano@hotmail.com
 
Thanks for your help.
I dont have any idea about &quot;dinamically populate an option box&quot; is there anyway populate the contact list without loosing data I already entered andwithout refresing the main input form?
Can you give me some info?
Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top