PDA

View Full Version : Can't access form field from previous page


paulgami
08-23-2006, 04:38 PM
I've built a multipage form using QuickForm_Controller. It has 5 pages, plus a final confirmation page, not too dissimilar to a shopping cart's checkout functionality.

If I'm on page3 and want to reference a particular field on that page in javascript I use:page3.fieldname.value and it works just fine.

Is it possible to reference fields on other pages? When I try to reference an item on page2 from page3, for example, I get this error:

Error: page2 is not defined
Source File: http://testbox/formtest.php?_qf_page3_display=true
Line: 1

trim9001
08-23-2006, 08:43 PM
It is possible to reference other fields on other pages. There are several ways to do this. If you would like to find out how to do this, then go to http://www.javascriptkit.com.:thumbsup:


:cool: :p ;) :eek: :mad: :rolleyes: :) :confused:

percepts
08-23-2006, 11:52 PM
one method is to put data in hidden form fields.

to do that you must know what the post data fields are called which you may or may not already know. You can populate them using PHP if necessary.

php function:

import_request_variables("gp", "myPrefix_");

will expose all the variables to PHP if they are not already and then you just set the value of your hidden fields with the variables you want. e.g.

<input name="someVar" type="hidden" value="<?PHP echo $myPrefix_someVarFromImportRequest;?>" />

then you can access the form value from javascript.


or

you could expose the post variables to PHP using:

import_request_variables("gp", "myPrefix_");

and then inside some javascript code you just say:

var a = <?PHP echo $myPrefix_someVar;?>