Topic: Formular - Dropdown ( Select Field ) in php Site
Hi Guys, i want to create a dropdown field in a formual via php. the dropdown works ( all options in the select are created normal ).
by submitting all the field to another site i receive all fields respectively all values of the fields of the formular exept the value of the dropdown field...and i don't know why.
Script of Dropdown:
echo("
<div class='modal fade' id='exampleModalLongSC".$KitchConfigID."' tabindex='-1' role='dialog' aria-labelledby='exampleModalLongTitleSC".$KitchConfigID."' aria-hidden='true' style='display: none;'>
<div class='modal-dialog modal-dialog-scrollable' role='document'>
<div class='modal-content'>
<form id='contact-form".$KitchConfigID."' name='contact-form".$KitchConfigID."' action='_pages/_kitchenconfig/adm_saveKitchConfig.php?Nav=".$NavHash."&kcid=".$KitchConfigID."' method='POST'>
<div class='modal-header'>
<h5 class='modal-title' id='exampleModalLongTitleSC".$KitchConfigID."'>
<b>".$KitchConfig."</b>
</h5>
<button form='contact-form".$KitchConfigID."'type='button' class='close' data-dismiss='modal' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
<div class='modal-body'>
<div class='row'>
<div class='col-sm-12'>
<div class='md-form mb-0 form-sm'>
<input value='".$KitchConfig."' type='text' id='configname".$KitchConfigID."' name='configname".$KitchConfigID ."' class='form-control'>
<label for='configname".$KitchConfigID ."' class=''>Config Name:</label>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-12'>
<div class='md-form mb-0 form-sm'>
<select id='designer".$KitchConfigID."' name='designer".$KitchConfigID."' class='mdb-select md-form' searchable='Search here..'>");
$designersql = "SELECT * FROM `tbl_contacts` ORDER BY `FirstName`";
$resultdesigner = $conn->query($designersql);
if ($resultdesigner->num_rows > 0) {
$resultdesigner->MoveFirst;
while($rowdesigner = $resultdesigner->fetch_assoc()) {
$DesignerName = $rowdesigner["FirstName"]." ".$rowdesigner["LastName"];
$DesignerID = $rowdesigner["ContactID"];
if($rowdesigner["ContactID"]==$rowkitch["Designer"]){
echo("<option value='designer' selected='selected'>".$DesignerName."</option>");
}
else {
echo("<option value='designer'>".$DesignerName."</option>");
}
}
}
echo("</select>
<label for='designer".$KitchConfigID."' class=''>Designer:</label>
</div>
</div>
</div>
<div class='row'>
<div class='col-lg-12'>
<div class='md-form mb-0 form-sm'>
<input value='".$KitchReason."' type='text' id='reason".$KitchConfigID."' name='reason".$KitchConfigID."' class='form-control'>
<label for='reason".$KitchConfigID."' class=''>Reason:</label>
</div>
</div>
</div>
<div class='row'>
<div class='col-lg-12'>
<div class='md-form mb-0 form-sm'>
<textarea type='text' id='keynote".$KitchConfigID."' name='keynote".$KitchConfigID."' class='md-textarea form-control'>".$KitchKeyNote."</textarea>
<label for='keynote".$KitchConfigID."' class=''>Key Note:</label>
</div>
</div>
</div>
<div class='row'>
<div class='col-lg-12'>
<div class='md-form mb-0 form-sm'>
<textarea type='text' id='comment".$KitchConfigID."' name='comment".$KitchConfigID."' class='md-textarea form-control'>".$KitchComment."</textarea>
<label for='comment".$KitchConfigID."' class=''>Comment:</label>
</div>
</div>
</div>
<br>
<div class='row'>
<div class='custom-control custom-checkbox custom-control-inline'>
".$KitchStdDetail."
<label class='form-check-label' for='stdchkbox".$KitchConfigID."'>Standard</label>
</div>
<div class='custom-control custom-checkbox custom-control-inline'>
".$KitchActDetail."
<label class='form-check-label' for='activchkbox".$KitchConfigID."'>Activ</label>
</div>
</div>
</div>
<div class='modal-footer'>
<div class='container col-sm-12'>
<div class='md-form mb-0 float-left'>
<small><small> Created: ".$KitchCreatedBy." ( ".$KitchCreatedDate." )
<br/>
Last Edit: ".$KitchLastEditBy." ( ".$KitchLastEditDate." )
</small></small>
</div>
<div class='md-form mb-0 float-right'>
<button type='submit' class='btn btn-outline-danger waves-effect btn-sm float-right'>Save <i class='fas fa-magic ml-1'></i></button>
</div>
</div>
</div>
</form>
</div>
</div>
");
on the forwarded Site: all Values could be requested via $_Post ... only the select field is empty ( By the way...also the checkbox is empty in case that the checkbox is not checked ) ... maybe you also have an Idea for that.
The code on that page is:
<?php
include('../../_admins/db_connection.php');
$NavHash = $_GET["Nav"];
$upd_KitchConfigID = $_GET["kcid"];
$upd_KitchConfig = $_POST["configname$upd_KitchConfigID"];
$upd_KitchConfigDesigner = $_POST["designer$upd_KitchConfigID"];
$upd_KitchConfigReason = $_POST["reason$upd_KitchConfigID"];
$upd_KitchConfigKeyNote = $_POST["keynote$upd_KitchConfigID"];
$upd_KitchConfigComment = $_POST["comment$upd_KitchConfigID"];
$upd_KitchConfigStandard = $_POST["stdchkbox$upd_KitchConfigID"];
$upd_KitchConfigActiv = $_POST["activchkbox$upd_KitchConfigID"];
echo("upd_KitchConfigID: <b>".$upd_KitchConfigID."</b><br>");
echo("upd_KitchConfig: <b>".$upd_KitchConfig."</b><br>");
echo("upd_KitchConfigDesigner: <b>".$upd_KitchConfigDesigner."</b><br>");
echo("upd_KitchConfigReason: <b>".$upd_KitchConfigReason."</b><br>");
echo("upd_KitchConfigKeyNote: <b>".$upd_KitchConfigKeyNote."</b><br>");
echo("upd_KitchConfigComment: <b>".$upd_KitchConfigComment."</b><br>");
echo("upd_KitchConfigStandard: <b>".$upd_KitchConfigStandard."</b><br>");
echo("upd_KitchConfigActiv: <b>".$upd_KitchConfigActiv."</b><br><br>");
echo("NavHash: <b>".$NavHash."</b><br>");
?>
I receive an Notice on that page: "Undefined index: desinger2 in ...." This notice i receive for the dropdown field and the checkbox
i hope you can help me in that case?!!!
thnx so much in advance. BR, Max
PS: Sorry...i'm a newby ( so the code seems not that professional )
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.18.0
- Device: Laptop
- Browser: google chrome
- OS: Wondows 10
- Provided sample code: No
- Provided link: No
Grzegorz Bujański staff commented 5 years ago
Hi. It doesn't look like a problem with our package. I'm not very good at php, but I don't see a function that would pass the form data on submit to another page. Besides, I wonder why you use the get method alternately with the post method?
DaMaxl premium commented 5 years ago
Hey Gregorz, thnx for your reply...nope...no prob with the package. GET - POST method: ...is just for some testing stuff ;-)
Grzegorz Bujański staff commented 5 years ago
I understand. Can you show the code responsible for getting the value from selecta and passing it to another page?
DaMaxl premium commented 5 years ago
Hey Grzegorz, i tried some staff...
it is not possible by using the followed class: ' class='mdb-select md-form'
BUT with ' class='md-select md-form'
With "mdb-select" the formular do not forward this field ( no variable will be created in the form array ).
With "md-select" it does. Do you know why this can happen? BR
Grzegorz Bujański staff commented 5 years ago
I can't tell without code... I need to see the code you use to retrieve the value. Then I can check why it doesn't work
DaMaxl premium commented 5 years ago
Hi Grzegorz,
the select field:
its a normal formular with "POST" method
the code to retrieve ( php ):$upd_KitchConfigDesigner = $_POST["designer$upd_KitchConfigID"]
more information is written i the request above. There you can see more parts of the codes.
Here is another example to show that some select fields are working and some not:
https://mdbootstrap.com/snippets/jquery/damaxl/2114839?action=forum_snippet
there should be in the first column: - Designer ( not working )
in the scond column: - Product Area ( ok ) - Material Typ ( not working ) - Article Typ ( ok) - Article Row ( not working ) - Measure ( not working )
-> that two that are working...there is no possibility to make it searchable ;-(