Avatar of lenamtl
lenamtl
Flag for Canada asked on

Ajax modal form with select2

Hi,

I'm using Select2 on all regular form PHP page and this is working ok.

I need to add a select2 field to an existing ajax form which is a modal php form.
I don't have much experience with Ajax so I'm not sure which value to use to replace adduser-user_division_id into the select
usually I use a variable but I don't what to do with this one
The result give me empty list
error: Notice: Undefined index: division_id

The same modal used to add / edit the infos

Let me know if you need other info.


Form part
<div class="form-group">
	<label class="control-label col-md-3" for="adduser-user_division_id">
		<?php echo ASLang::get('division'); ?><span class="required">*</span>
	</label>							
	<div class="controls col-md-9">
		<?php $divisions = $db->select("SELECT * FROM `as_division`"); ?>
			<select id="adduser-user_division_id" name="adduser-user_division_id" class="form-control select2-single select2-hidden-accessible input-sm" tabindex="-1" aria-hidden="true">
				<?php foreach($divisions as $division): ?>
					<option></option>
						<?php
							echo '<option value="' . $division["division_id"] . '"' .
							(( adduser-user_division_id ==  $division["division_id"]) ? ' selected' : '') . '>' .
							 $division["division_name"] .   '</option>';
						?>
					<?php endforeach; ?>									
			</select>	
	</div>
</div>

Open in new window

AJAXPHP

Avatar of undefined
Last Comment
lenamtl

8/22/2022 - Mon
SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
lenamtl

ASKER
It's look like as the form get dynamically filed by js this will require some extra js and php adjustment otherwise it won't work.
I may decide to rewrite the form to a non popup page as there will have more field to add

I will do some test and the weekend and get back with more info.
ASKER CERTIFIED SOLUTION
lenamtl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
lenamtl

ASKER
I have found another method to fix the problem
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck