Jump to content

[FP5] Token Question - 2 Forms on a Page


This topic is 6488 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Token setting question

You have two forms on the same page

One Form with two text input fields - "label" and "zip"

When the text is entered, can you set "-token.0" to "label" and "-token.1" to "zip"

Another Form with two hidden tokens set to the text entered fields.

I would guess not, since it does not seem to work

Javascript??

(the goal is to choose a FIND on search.html with the "label" and "zip" entries OR

pass the tokens "-token.0" and "-token.1" to the distance.html page)

<FORM ACTION="FMPro" METHOD="post" NAME="form1">

<b>Search by Label<br>

<INPUT TYPE="hidden" NAME="-db" VALUE="database.fp5">

<INPUT TYPE="hidden" NAME="-lay" VALUE="layoutweb">

<INPUT TYPE="hidden" NAME="-format" VALUE="search.html">

<INPUT TYPE="hidden" NAME="-error" VALUE="searcherror.html">

<INPUT TYPE="hidden" NAME="-Max" VALUE="10">

<INPUT TYPE="text" NAME="label" ID="label" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.0" ID="-token.0" VALUE="label">

<br>

And / Or Zip Code<br>

<INPUT TYPE="text" NAME="zip" ID="zip" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.1" ID="-token.1" VALUE="zip"> <br>

<INPUT TYPE="image" NAME="-find" SRC="images/button_go.jpg" VALUE="">

</FORM>

<br> <br>

<FORM ACTION="FMPro" METHOD="post" NAME="form2">

Search by Distance:</b></font>

<INPUT TYPE="hidden" NAME="-db" VALUE="database.fp5">

<INPUT TYPE="hidden" NAME="-lay" VALUE="layoutweb">

<INPUT TYPE="hidden" NAME="-format" VALUE="distance.html">

<INPUT TYPE="hidden" NAME="-error" VALUE="distanceerror.html">

<INPUT TYPE="hidden" NAME="-Max" VALUE="10">

<INPUT TYPE="hidden" NAME="label" ID="label" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.0" ID="-token.0" VALUE="label">

<INPUT TYPE="hidden" NAME="zip" ID="zip" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.1" ID="-token.1" VALUE="zip"> <br>

<INPUT TYPE="image" NAME="-find" SRC="images/button_go.jpg" VALUE="">

</FORM >

Thank you for reading this.

FileMaker Version: 5

Platform: Mac OS 9

Link to comment
Share on other sites

I not exactly sure what you are trying achieve here, however you are correct in that http/html does not send two Forms.

To assign entered values to Tokens on the same page you will need to use some Javascript. For example:

<head>

<script>

function assignTokens ()

   {

   document.form1.elements["-token.0"].value = document.form1.label.value;

   document.form1.elements["-token.1"].value = document.form1.zip.value;

   document.form1.submit();

   }

</script>

</head>

<body><FORM ACTION="FMPro" METHOD="post" NAME="form1" onsubmit="assignTokens(); return false;">

<b>Search by Label<br>

<INPUT TYPE="hidden" NAME="-db" VALUE="database.fp5">

<INPUT TYPE="hidden" NAME="-lay" VALUE="layoutweb">

<INPUT TYPE="hidden" NAME="-format" VALUE="search.html">

<INPUT TYPE="hidden" NAME="-error" VALUE="searcherror.html">

<INPUT TYPE="hidden" NAME="-Max" VALUE="10">

<INPUT TYPE="text" NAME="label" ID="label" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.0" ID="-token.0" VALUE="label">

<br>

And / Or Zip Code<br>

<INPUT TYPE="text" NAME="zip" ID="zip" SIZE="20" MAXLENGTH="150">

<INPUT TYPE="hidden" NAME="-token.1" ID="-token.1" VALUE="zip"> <br>

<INPUT TYPE="hidden" NAME="-find"> 

<INPUT TYPE="image" NAME="-find" SRC="images/button_go.jpg" onclick="Javascript:assignTokens();">

</FORM>

Good Luck.

Garry

Link to comment
Share on other sites

Tried the script.

Goes to the results page and the script apparently is not working...

<INPUT TYPE="text" NAME ="label" VALUE="[FMP-CurrentToken:0]" size=20>

<INPUT TYPE="text" NAME="-Token.0" VALUE=""> Token.0 <br>

CurrentToken0 = [FMP-CURRENTTOKEN:0]

Do not show any values, either on the page or the source

LABEL = [FMP-field: label]

Does show the data in the database from the find

Am searching the internet for another example of the script.

I added the language="javascript" - assume this is okay?

<script language="JavaScript">

function assignTokens ()

{

document.form1.elements["-token.0"].value = document.form1.label.value;

document.form1.elements["-token.1"].value = document.form1.zipcopy.value;

document.form1.submit();

}

</script>

thanks for hint...

Link to comment
Share on other sites

>Token setting question

>You have two forms on the same page

>One Form with two text input fields - "label" and "zip"

>When the text is entered, can you set "-token.0" to "label" and "-token.1" to "zip"

>Another Form with two hidden tokens set to the text entered fields.

>I would guess not, since it does not seem to work

>Javascript??

Javascript is probably unnecessary. Good design is more important. Understanding how tokens are set and passed is very useful. Knowing how forms work is similarly very useful.

When you have two forms on the same page, the client can submit one or the other, not both. Looking at your two forms, if both were submittable, the client would need to be able to receive two different success.htm's (search.htm and distance.htm). Can't be done.

>(the goal is to choose a FIND on search.html with the "label" and "zip" entries OR

>pass the tokens "-token.0" and "-token.1" to the distance.html page)

Use the first form only and eliminate the second. Change the error.htm from searcherror.htm to distance.htm. The tokens then can be set so they are passed to either result.htm.

Link to comment
Share on other sites

I combined two answers that works for this purpose....

<!-- Script BEGIN Submitting a single form to multiple html pages with tokens set -->

<script language="JavaScript">

function submittoresults(){

document.form1.elements["-format"].value = "results.html";

var name0 = document.form1.elements["label"].value;

document.form1.elements["-token.0"].value = name0;

var name1 = document.form1.elements["zipcopy"].value;

document.form1.elements["-token.1"].value = name1;

document.form1.submit();}

function submittoresultsnext(){

document.form1.elements["-format"].value = "resultsnext.html";

var name0 = document.form1.elements["label"].value;

document.form1.elements["-token.0"].value = name0;

var name1 = document.form1.elements["zipcopy"].value;

document.form1.elements["-token.1"].value = name1;

document.form1.submit();}

</script>

<!-- Script END -->

It allows one form to be submitted to one of two pages depending on the submit button clicked.

Thank you for your time.

Link to comment
Share on other sites

This topic is 6488 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.