Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Copy data from one form to another?

by fmogavero (Monk)
on Mar 11, 2005 at 21:12 UTC ( [id://438811]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Copy data from one form to another?
in thread Copy data from one form to another?

I suppose it will be Javascript. I had one form which is populated by information from the database. Due to the limitation of one submit button per form I have a second form that has all hidden fields so I could capture the information that I need. I wanted to capture any changes so that the Database could be updated. I would use the param('value') but it gets set on the page load. That means that I would need to capture the information directly from the field so I could transfer it to the second form which has the database updating routine. I hope this explains it.

Replies are listed 'Best First'.
Re^5: Copy data from one form to another?
by jZed (Prior) on Mar 11, 2005 at 21:20 UTC
    I'm not sure what you mean by limitation of one submit buttom, forms can have any number of submit buttons and if they have different names or values, you can tell which was clicked when you get the form in a script. But here's where you've lost me again - why are there two forms? and what is the intended destination/result of submitting them?
      The first form is for searching the database. It can search on any of the fields and then return the results. i.e. type in a last name and the fields in the form get populated with the information from the database.

      I wanted to incorporate a way from that page to modify the data and update the database.

      The first submit button uses the same form to return search results. The other form would be for updating the database.

        Ok, great, now I understand what you want to do. Here's how I would do it. Forget about Javascript, that wouldn't help here. Don't use two forms, that confuses things (unless there are different fields in the search from and the edit form, in which case, this scenario would need to be modified).

        Make one form with two sumbit buttons both with the name "action" and one with a value "search" and the other with the value "edit".

        In your script, read param("action") and if it is "search", search the database and then redisplay the same form with the values filled in. If the action is "edit", update the database with the new information and then redisplay the same form again so they can search again. If there is no param("action"), that means the user is just starting so you display the same form, but with blanks.

        You only ever have one form, it just has different values filled in or blank depending on context. And you only have one script that does different actions with the database depending on the action param. Does that make sense?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://438811]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found