Auto-Complee Form in PHP

Thread Solved

Join Date: Aug 2008
Posts: 29
Reputation: derekcpt is an unknown quantity at this point 
Solved Threads: 2
derekcpt derekcpt is offline Offline
Light Poster

Auto-Complee Form in PHP

 
0
  #1
Aug 18th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 848
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 68
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Auto-Complee Form in PHP

 
0
  #2
Aug 18th, 2008
Originally Posted by derekcpt View Post
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.
You are being way too vague here, why don't you post what you have done so far and maybe someone might be able to help you.
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 29
Reputation: derekcpt is an unknown quantity at this point 
Solved Threads: 2
derekcpt derekcpt is offline Offline
Light Poster

Re: Auto-Complee Form in PHP

 
0
  #3
Aug 18th, 2008
k ;-)

Will do
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 383
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 35
langsor langsor is offline Offline
Posting Whiz

Re: Auto-Complee Form in PHP

 
0
  #4
Aug 18th, 2008
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
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. // open your pop-up window ...
  5. var pup = window.open('pup.html','pup');
  6.  
  7. function populate_form ( val1, val2 ) {
  8. var form = document.getElementById('my_form');
  9. for ( var i = 0; i < form.elements.length; i ++ ) {
  10. var element = form.elements.item(i);
  11. switch ( element.name ) {
  12. case 'field_1': element.value = val1; break;
  13. case 'field_2': element.value = val2; break;
  14. }
  15. }
  16. }
  17.  
  18. </script>
  19. </head>
  20. <body>
  21. <form id="my_form">
  22. <input type="text" name="field_1" />
  23. <input type="text" name="field_2" />
  24. </form>
  25. </body>
  26. </html>

pup.html
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function send_to_parent ( target ) {
  5. var val1 = target.getAttribute('val1');
  6. var val2 = target.getAttribute('val2');
  7. opener.populate_form( val1, val2 );
  8. return false;
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <a href="javascript:" val1="one" val2="two" onClick="send_to_parent(this)">Populate 'one','two'</a><br />
  14. <a href="javascript:" val1="three" val2="four" onClick="send_to_parent(this)">Populate 'three','four'</a>
  15. </body>
  16. </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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 383
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 35
langsor langsor is offline Offline
Posting Whiz

Re: Auto-Complee Form in PHP

 
0
  #5
Aug 18th, 2008
In PHP you would have to submit the child window with the parent window as the form action ...
  1. <form aciton='parent.php" method="POST">
  2.  
... and grab the submitted child form values in the parent window ...
  1. <?php
  2. $val1 = $_POST['val1'];
  3. ?>
... thus reloading the parent page, and insert the values in the parent window form like this ...
  1. <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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 29
Reputation: derekcpt is an unknown quantity at this point 
Solved Threads: 2
derekcpt derekcpt is offline Offline
Light Poster

Re: Auto-Complee Form in PHP

 
0
  #6
Aug 19th, 2008
Hey.

This is exactly what I was looking for.

Thanx so much.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 713 | Replies: 5
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC