Eric Robinson Posted July 8, 2004 Posted July 8, 2004 This is a question for FMP 6 Unlimited using CDML. I have a 9 page form, used to populate a single record. I want the user to be able to access the pages in any order by clicking on some folder tabs. So far, I have two different thoughts, neither of which works: 1) I can make the folder tabs simple anchors, which lead to the proper page of the form. However, if I do this, the data typed on the current page will be thrown away. 2) I can make the folder tabs submit buttons, which will definitely save the data. However, they cannot be made to lead to different pages -- all of the submit buttons will lead to the same format file. Now, if I knew the user was going to use the pages in order, from 1 to 9, I would simply put a submit button on each page (labelled "Continue"), and make sure that the -Format variable references the next page of the form. However, the user needs to reach any arbitrary page with a single click, while saving anything typed on the current page. Is this possible?
Damocles Posted July 8, 2004 Posted July 8, 2004 Have you tried using the "Link" command? My CDML has never been outstanding, so this may have a major flaw, but this is how I would try it. Use these as the tabs... <a href="[FMP-Link: ra]&-Format=Form_Page_1.htm&-edit"> Goto Page 1</a> <a href="[FMP-Link: ra]&-Format=Form_Page_2.htm&-edit"> Goto Page 2</a> Etc.... Of course, you'd have to design it in such a way that the user gets to these pages by first creating the record. The record number would be part of the link used to get to the page (and subsequently passed on...) Hope this helps. Paul
Eric Robinson Posted July 8, 2004 Author Posted July 8, 2004 Hi Damocles, Won't that throw away the data on the current page of the form? As such, it is essentially identical to my thought 1). Yep - I just tried that out, and it does what I expected. Let's say you are on page 1 of the form, type in some data, then hit the link to page 2. The stuff you typed into page 1 gets tossed, because the link does not actually do anything with the data you just typed. Now, if the URL had some way to reference a text area, it could work. Say, with code like "...&MyField=[FMP-Input: MyTextArea]&-Edit" you could use stuff the contents of MyTextArea into MyField. But no such tag seems to exist.
Steve T. Posted July 9, 2004 Posted July 9, 2004 Hi, Eric! It shouldn't matter that you have different pages... you are still accessing the same FM record, so if you keep using <INPUT TYPE="hidden" NAME="-recID" VALUE="[FMP-CurrentRecID]"> on every page, the appropriate edits will work. Your problem is basically how to change the -format page by user selection. I remember Garry Claridge helping someone with something similar using a dropdown menu. THAT person wanted to the user to select a different -db to query, but the logic should work for a -format page as well. Here's a clipping of Garry's post... You can do this: <select name="-db"> <option value="mydb1.fp5">Select DB1</option> <option value="mydb2.fp5">Select DB2</option> <option...... </select> Good Luck. Garry I was surprised to find it works great. It's not tabs, but it should work as well for -format pages as it did for -db. --ST
Garry Claridge Posted July 9, 2004 Posted July 9, 2004 You can also use some Javascript to replace the "-format" value. For example: document.myform.elements["-format"].value = "pagex.html"; Good Luck. Garry
Eric Robinson Posted July 9, 2004 Author Posted July 9, 2004 Thanks guys, That gives me a better understanding. The drop down to select a format file sounds intriguing. I could set the next page as the default. (Of course, it doesn't satisfy my original goal: one click that both submits the data and jumps to an arbitrary page number. But it's still nifty in it's own way.) The javascript snippet looks like a good way to assign an arbitrary format file. The only question is whether the javascript could also submit the form on the current page before moving to the new page. If not, then wouldn't this just be another case 1), which throws the data away?
Unable Posted July 9, 2004 Posted July 9, 2004 Let's see, a nine page form. That sounds like fun. You want the client to be able to select any of the 9 pages in no particular order. Simple in concept. It will take a bit of basic design. Each page has a (submit form) -new and each page has an -edit form and each page has the navigation options (which should also dim those pages already visited). Control everything using the fmp-if, fmp-else and tokens (you have ten of them). If your original query contains all we need to know then it really sounds quite simple to me. Have fun.
Steve T. Posted July 9, 2004 Posted July 9, 2004 Hi, Eric! I'll leave the JS part to Garry or other JS-savy folks, but I think the drop down will work the way you want it... I think, I think... user is on a form page, changes some data, selects the next page to go to from the drop down, hits the submit button, their data is saved to the record and they end up at whatever page they selected JS is probably better, but I haven't learned that yet to any significant level of proficiency. --ST
Eric Robinson Posted July 9, 2004 Author Posted July 9, 2004 Each page has a (submit form) -new and each page has an -edit form and each page has the navigation options (which should also dim those pages already visited). Control everything using the fmp-if, fmp-else and tokens (you have ten of them). I thought about this, but I think it suffers the same problem. If the user clicks one of the navigation buttons, the current form gets thrown away.
Unable Posted July 9, 2004 Posted July 9, 2004 Not so. The first submit creates the new record. All subsequent submits are edits. It can all be controlled with fmp-if statements, etc. on the results page. It is a matter of design. A reminder, -edit requires -recid.
Garry Claridge Posted July 10, 2004 Posted July 10, 2004 Some type of "Registration" process prior to any page of the Form being opened could solve the "-new/-edit" situation. Good Luck. Garry
Eric Robinson Posted July 12, 2004 Author Posted July 12, 2004 Not so. The first submit creates the new record. All subsequent submits are edits. It can all be controlled with fmp-if statements, etc. on the results page. It is a matter of design. A reminder, -edit requires -recid. Could you explain this a little mre fully? I think I understand how to us FMP-If to control whether an -Edit or -New tag is processed, and to pass the RecID to ensure that they are operating on the same record. What I'm not understanding, and I ask for your patience on this, is how to construct the navigation buttons. In your solution, are the navigation buttons URL-style anchors? I assume not, since URL-style anchors cannot submit form data. (Please let me know if I am wrong -- yes, they can be used to execute -New and -Edit actions, but the data they send must be contained in the URL, not text areas on a form). Or, are the nav buttons are input buttons (type="submit")? If so, where is the distinction between pressing the "page 2" button and the "page 3" button? In both cases, won't they go to the page specified by the form (the hidden input for -Format)? That hidden input portion of the form has no idea which button will be pressed.
Unable Posted July 12, 2004 Posted July 12, 2004 First, Garry has a point that if you have the client "register" for the test (create the new record on the way) then you will need only -edits which will simplify things a bit. The navigation (buttons, tabs, etc. which can be created with images replacing the buttons normally generated) are the -edit submits. Thus if the client starts on page 3, she should not be allowed to select page 3 but whichever other next page is desired. I have not tried this but each -edit submit would also include the -format code to return the page selected.
Eric Robinson Posted July 12, 2004 Author Posted July 12, 2004 ...each -edit submit would also include the -format code to return the page selected. That's the crux of the problem. How does an <input type=submit name=-Edit value="p2"> specify a -format code?
Garry Claridge Posted July 12, 2004 Posted July 12, 2004 You can use some Javascript to test if a "FMP-CurrentRecID" exists: <form name="myform" action="FMPro" method="POST> <input type="hidden" name="-db" ......... <script>currentrec = "[FMP-CurrentRecID]"; if (currentrec > 0) { document.write('<input type="hidden" name="-recid" value="[FMP-CurrentRecID]">'); document.write('<input type="hidden" name="-edit">'); } else { document.write('<input type="hidden" name="-new">'); }; </script> Enter Data: <input type="text" ...... <input type="submit" name="" value="Submit Form"> </form> This will use "-edit" if the [FMP-CurrentRecID] is a number, which it will be if the Form comes from WebCompanion. It comes from a direct URL the [FMP-CurrentRecID] will not be rendered and hence "-new" will be used. Hope this helps. Garry
Unable Posted July 13, 2004 Posted July 13, 2004 Eric, I have inadvertently led you down the primrose path and I apologize. While the concept was simple it just doesn't work. I was thinking of nesting the forms so there were many buttons, but that just does not work. I did try that. Now that I've tried that I can say I don't know how to submit from a randomly selected button to yield a randomly selected result.htm. If you can use JS to add inputs for the result.htm, submit-edit and /form to the randomly selected button that might do it. But I can't help with the JS design on that.
Eric Robinson Posted July 14, 2004 Author Posted July 14, 2004 No problem-- it helped clarify my thinking, and I learned a few nifty things along the way. The javascript looks useful, but I am going to avoid it as much as possible, to run for a wider range of users. I think I'm just going to use a real simple solution: * The page can be loaded with with forms or without -- controlled with FMP-If. * When loaded with forms, the folder tabs are disabled. Instead, there is an ordinary submit button, which performs an -Create or -Edit action, and loads the next page with forms. A cancel button is a straight URL that -Views the current page without forms. * When loaded without forms, the folder tabs are enabled as simple URL-style anchors that -View the appropriate page without forms. There is no form and therefore no submit button. If the user clicks on any of the displayed data, the page loads again with forms so that it can be edited -- the data is a giant anchor.
Unable Posted July 15, 2004 Posted July 15, 2004 Garry, for my own edification, can the javascript do a "document write" as I suggest, depending on the button the client selects. I don't need the code; I believe it would be similar to the JS "if" you provided above. A simple yes or no will do. Thanks.
Garry Claridge Posted July 15, 2004 Posted July 15, 2004 Unable, Yes, the Javascript can "submit" any Form on a page. It can also change the value of the "-format" tag. It may not be a "document.write" as these are usually rendered while the page is loading. All the best. Garry
Recommended Posts
This topic is 7428 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 accountSign in
Already have an account? Sign in here.
Sign In Now