Re: Populate input from another form

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

 



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 assume that you really, really need to have multiple forms here? Different targets? Otherwise, why the two forms?

Realizing that you are using html 5 syntax here, and that html5 is not supported fully on many browsers (that you may have to support), you are going to have to use some javascript to grab the input from elements outside your form and populate the hidden ones inside your form. Not a difficult thing.

In your onsubmit handler, simply do

document.getElementById(fld1_hidden).value = document.getElementById(fld1).value;


--
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