Skip to main content
Known Participant
April 6, 2011
Question

Dynamic forms in php

  • April 6, 2011
  • 1 reply
  • 404 views

I'm trying to populate a drop down box in a form(form2) dynamically using a form variable from a different form(form1) on the same php page. does anyone know what i should set the action as for form 1 so that when form 1 is submitted form 2 is populated from the form variable? Any advice is appreciated.

This topic has been closed for replies.

1 reply

Known Participant
April 8, 2011

Your could use either method, POST or GET.   <form action='' method="post">

Then put code such as the following somewhere, probably above the forms.

if ($_POST['name_of_form_one_submit']){

$variable1 = $_POST['variable1'];

}

Then your dropdown in form2 will dynamically be populated with the variable as follows:

<select name='drop_down_variable_name'>

option value= "<?php echo $variable1 ?>"><?php echo $variable1 ?></option>

Participant
April 13, 2011

Thanks for the answer. I have a similar problem. Going to try this out.