| | |
Auto-Complee Form in PHP
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 29
Reputation:
Solved Threads: 2
I'm having a for where I can create invoices. Now I'm having the form fields where I have to fill it out with the customer's data. Well I don't want to fill out existing customer's data everytime. So I am having a link which opens up a page with a list of all existing customers. Now how can I get it to auto complete the form fields when clicking on the customer in the popup page? In other words, when clicking on a customer in the popup page, the form fields have to be auto-completed in the parent page.
•
•
•
•
I'm having a for where I can create invoices. Now I'm having the form fields where I have to fill it out with the customer's data. Well I don't want to fill out existing customer's data everytime. So I am having a link which opens up a page with a list of all existing customers. Now how can I get it to auto complete the form fields when clicking on the customer in the popup page? In other words, when clicking on a customer in the popup page, the form fields have to be auto-completed in the parent page.
Last edited by R0bb0b; Aug 18th, 2008 at 9:09 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
Join Date: Aug 2008
Posts: 383
Reputation:
Solved Threads: 35
I think I know what you're talking about ...
The link you open is a new window and you have selections in that window ... when you click on a selection you want to populate the original (main) window form fields ...
If this is what you mean, then try something like this example
main.html
pup.html
If this is not what you mean, then please clarify ...
Thanks
[edit]
Only problem is, this is all javascript ... doing this in PHP is another matter ... one minute
[/edit]
:-\
The link you open is a new window and you have selections in that window ... when you click on a selection you want to populate the original (main) window form fields ...
If this is what you mean, then try something like this example
main.html
PHP Syntax (Toggle Plain Text)
<html> <head> <script type="text/javascript"> // open your pop-up window ... var pup = window.open('pup.html','pup'); function populate_form ( val1, val2 ) { var form = document.getElementById('my_form'); for ( var i = 0; i < form.elements.length; i ++ ) { var element = form.elements.item(i); switch ( element.name ) { case 'field_1': element.value = val1; break; case 'field_2': element.value = val2; break; } } } </script> </head> <body> <form id="my_form"> <input type="text" name="field_1" /> <input type="text" name="field_2" /> </form> </body> </html>
pup.html
PHP Syntax (Toggle Plain Text)
<html> <head> <script type="text/javascript"> function send_to_parent ( target ) { var val1 = target.getAttribute('val1'); var val2 = target.getAttribute('val2'); opener.populate_form( val1, val2 ); return false; } </script> </head> <body> <a href="javascript:" val1="one" val2="two" onClick="send_to_parent(this)">Populate 'one','two'</a><br /> <a href="javascript:" val1="three" val2="four" onClick="send_to_parent(this)">Populate 'three','four'</a> </body> </html>
If this is not what you mean, then please clarify ...
Thanks
[edit]
Only problem is, this is all javascript ... doing this in PHP is another matter ... one minute
[/edit]
:-\
Last edited by langsor; Aug 18th, 2008 at 9:50 pm.
•
•
Join Date: Aug 2008
Posts: 383
Reputation:
Solved Threads: 35
In PHP you would have to submit the child window with the parent window as the form action ...
... and grab the submitted child form values in the parent window ...
... thus reloading the parent page, and insert the values in the parent window form like this ...
The child window would be a form with multiple, probably <input type="hidden" ...> values for each person you wanted to submit the values for.
Hope this helps
[edit]
I would do it with JavaScript personally, since it's for you and you know JS is supported.
[/edit]
PHP Syntax (Toggle Plain Text)
<form aciton='parent.php" method="POST">
PHP Syntax (Toggle Plain Text)
<?php $val1 = $_POST['val1']; ?>
PHP Syntax (Toggle Plain Text)
<input type="text" name="val1" value="<? print $val1; ?>" />
The child window would be a form with multiple, probably <input type="hidden" ...> values for each person you wanted to submit the values for.
Hope this helps
[edit]
I would do it with JavaScript personally, since it's for you and you know JS is supported.
[/edit]
Last edited by langsor; Aug 18th, 2008 at 9:48 pm.
![]() |
Other Threads in the PHP Forum
- Previous Thread: How do I make Tabs and Logos?
- Next Thread: Getting the sum of amounts in php - please assist
Views: 713 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache array auto box broken buttons cakephp cart check checkbox class classes cms code cookies database date development directory display download dropdown drupal dynamic echo email error file files folder form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link login loop mail menu mlm mod_rewrite multiple mysql order parse password paypal php problem query radio redirect regex remote rows script search security select server session soap sort sorting source sql string structure syntax table tutorial unicode update upload url user validation variable video web website wordpress xml





