Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Ok, Perl gurus. I bet the answer to this question is very simple however I'm beating my head on the monitor cause I can't find the answer.

I m working on a basic submit form for my page, where users fill out textfields and i carry the variables to the other page, they have a few more questions and proceed to the next step. Then I have a confirmation page with all the varibales printed out on it. Now, I want to have <a href> link next every varibale saying EDIT and give them ability to change it before sumbitting the form. The question is how do i assign a value to the varibale in HTML link?? basicaly the page would look like that:
Company Name :[company] Edit Contact Name: [contact] Edit Whatever: [whatever] Edit

So , let's say I want to change the value of [company]. I need to click on Edit next to it, and have it do something like that [edit]=[company], and then open a page having [edit] in the textfield so they can change the value of it. And then after clicking on Submit return to the previous page and reasign the value so [[company]=[edit]
I hope it explains what im looking for. Thank you.

Replies are listed 'Best First'.
Re: Assign perl value in html link
by dws (Chancellor) on Oct 04, 2002 at 19:17 UTC
    I want to have <a href> link next every variable saying EDIT and give them ability to change it before submitting the form.

    Treat editing as another form submission that you have to carry all of the variables through, except in this case the only variable visible to the user is the one they're editing (all others are hidden). To return to the previous page you'll need to either encode that page as an argument to the CGI the edit form submits to, or use a hidden field to hold the URL, and rely on the CGI to redirect to it.

    This'll require that you have an edit button instead of a link.

      The tricky part is I dont really want to create a separe page for each field because i have over 20 of them.
      I guess I can carry on all the hidden variables to edit page and also have this: <input name="edit" type="hidden" id="edit" value="[company]">
      ...BUT.... I can't figure out, how I would assign to what varibale [edit] needs to be assigned. How can I make EDIT equal to the varibale user wants to change, and then when they return to confirmation page how I make that field equal to EDIT?
        The tricky part is I dont really want to create a separe page for each field because i have over 20 of them.

        You can probably get by with a small number of generic edit pages, depending on the type of data you'll be editing. (If everyhing can be editing in a 20 character field, you can use a single edit page).

        Here's how it works: You already have a form that contains some number of visible and invisible fields. Add alternate "Submit" buttons labeled "Edit". Give these buttons the name of the field you want to edit (or some name from which the target field name can be derived).

        When one of these buttons is pressed, it submits the form. The CGI that catches the submit needs to recognize that an edit button was pressed (as opposed to an "I'm done with this page" button), and respond by producing an HTML page that includes a form. The form has an edit field for the field being editing, and all other form values hidden. The form action for this page is a CGI that handles the edit, and redirects back to something that will regenerate the page you started out on (e.g., your "confirmation" page).

Re: Assign perl value in html link
by seattlejohn (Deacon) on Oct 04, 2002 at 19:14 UTC
    Something like this:
    <a href="/cgi-bin/myscript.pl?edit=company">Edit</a>

    Then your script will need to look for the value of the edit param to decide which form to pop up.

Re: Assign perl value in html link
by Anonymous Monk on Oct 04, 2002 at 22:51 UTC
    Maybe I'm missing something ....

    >"Then I have a confirmation page with all the varibales printed out on it."

    Is there any reason you can't carry the entered items over as "original" fields? What I mean is, instead of passing values and creating hidden items and creating links to editing forms that rely on the hidden items .... , why not pass the values and create the same field (with the value entered)? I've seen this done all the time with shopping carts ... and this format allows the user to revise the field (or not).

    As I said in the beginning, maybe there's something I'm missing?

    --- A newbie who's just starting to understand the value of Monkdom