Link to home
Start Free TrialLog in
Avatar of sami_hung
sami_hung

asked on

copy text field data from one form page to another!

Hi All,

This is Sam. This time my question is going to be the most simple one I'd ever asked.

What command I should use to copy the text field "text1" data in the page "form1" to another text field "text2" in the page "form2"?

thisform.text2.value=thisform.text1.value

This is definitely wrong and an error message displays "text2 does not exist."

Sam.
Avatar of Clever_Bob
Clever_Bob
Flag of Australia image

Hi Sam, it looks like you're developing a website in ASP?

If so, the problem is that you can't directly copy data from one webpage to another

The best way to do this would be to set up a 'form' using a <form> tag and a submit button within the <Form> </Form> tags.

The Submit button takes you to the 'Form2' page and you can interpret the data from your first page there by referencing the objects on the form on your previous page
 
I should also have added, you need to use the request object to get your info from the second page... e.g..

a = Request("inputfield")

and your form tag should look like this

<form METHOD="post" ACTION="page2.asp" id="frmCreate" name="frmCreate">

Avatar of sami_hung
sami_hung

ASKER

Hi Clever Bob,

Well one thing I have to make myself more clear is that I'm not developing a web page in ASP or something, but just using the old version of Visual Foxpro (V6.0). I should write in more details of my question, or actually a very simple question:

I now generated two forms ("form1.scx" and "form2.scx") and "form1" contains text field (text1) and "form2" contains text field (text2). I'm writing a search function in form2.scx in order to copy data from "text2" to "text1".

I had tried this way: "thisform.text1.value=thisform.text2.value"
As I run this command it generates an error message "text1 does not exist." (because text1 is not in "form2"). In other words I cannot use "thisform.text1.value" in search function.

Please help,
Sam.
have u tried using following?
form1.text1.value=form2.text2.value
Hi Sam

It will not work.
Since thisform is only the current form.

Tell me do you want the value of Form2 ,text2 to have the same value as form1 text1  at run time ?
which means form1 is also running and form2 is also running ?


Case -1
------------------
If you are calling form2 from form1 , you can do the fo,llowing

do form form2 with thisform.text1.value

In Init of Form2

lPAramter cFrm1txt1val
thisform.text2.value = cFrmtxt1val


This will put form1's text1's value in form2 text2 (i noticed it is reverse of what you asked...pls swap the forms accordingly :-))

************

Case 2
--------
If you are not calling the second form from first form
and it is an independent form ...and both can be selected from the menu and run simulataneously
then

in Form1

If vartype("Form2") = "O"
       thisform.text1.value = form2.text2.value    
Endif

-Archana


Hi archana,

Thanks for your idea. I think it works.
But what if more than 1 text field I'm concerning, say 2 text fields, 1 grid window and 2 other buttons. At grid window I want to use form2.search.click() to control the grid window and other 2 text fields in form1 to make it as enabled=.f., and 2 buttons as enabled=.f..

Can I write as follows:

     do form form2 with thisform.text1.value, thisform.text2.value, thisform.grid1.enabled, thisform.addbtn.enabled, thisform.editbtn.enabled

lparameter m.form1_value,m.grid1_enabled,m.addbtn_enabled,editbtn_enabled
thisform.text2.value=m.form1_value
m.grid1_enabled=.f.
m.addbtn_enabled=.f.
m.editbtn_enabled=.f.

Sam.
ASKER CERTIFIED SOLUTION
Avatar of arch_great
arch_great

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will put them in session variable

e.g.

on code behind of form 2:
Session("NameOfVarible")=thisform.text2.value

on code behind of form 1:
thisform.text1.value=Session("nameOfVarible")
Hi All,

This question seemed open for long, and I had found another way out to solve it. Thanks for all of you sharing your time with your precious solutions.