Re: Re: Populate input from another form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/2013 11:07 PM, tamouse mailing lists wrote:
On Fri, Mar 8, 2013 at 9:17 PM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx> wrote:
On 3/8/2013 2:45 PM, John Taylor-Johnston wrote:

I have a form

<form action="CRTP_Query.php" id="CRTP_Query" method="post"
target="_CRTP"><input value="Query" form="CRTP_Query"
type="submit"></form>

OnSubmit, I want to include data from another form (form="DPRform").

<input name="DPRsurname" type="text" form="DPRform" size="20"
value="<?php echo stripslashes($_POST["DPRsurname"]);?>">

I should use a hidden identical field and use form="CRTP_Query":

<input name="DPRsurname" type="hidden" form="CRTP_Query" value="<?php
echo stripslashes($_POST["DPRsurname"]);?>">

But I have no idea how to populate the hidden field with the data from
the viewable field. PHP cannot do this onsubmit, can it?

Anyone have an example to show me please?

Do I need to use jquery?

I thought that the new 'form' attrib did that for you?  No?

My understanding is that the new form attribute on input lets you put
an input tag *outside* any forms, and use the form= attribute to
indicate which form it should go with. I think this may be more useful
for mobile web apps than desktop browser apps. It doesn't let you copy
a form element from one form to another.

If you have multiple forms on one page, and want to submit data that
is placed in one form with another one, you will have to do that with
JS/jQeury. I don't have a ready example, but the basic concept is:

* capture the form submit using an onclick
* which calls a function that can gather up all the information from
the other forms, and
* build hidden form elements on the fly for the form you want to submit, and
* then programmatically perform the submit

This seems interesting enough that I might do up a tutorial on it when
I have some time.  Maybe Tedd already has one?

That's a different take than I thought it meant (the docs that is). Makes sense tho, if true. I thought from reading "one or more forms" in the docs I've seen, that it meant "allowing the input to be included in *all* of the forms mentioned in the attrib.

Something that should be tested by our OP here.

Of course the real problem is html 5 support.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux