Adamhumbug Posted April 29 Share Posted April 29 I have a function $(document).on('click', '#newFieldRow', function() { console.log('clicked') $html = `<div class='row mb-3'> <div class='col'> <input type='text' disabled class='form-control w-100' name='code[]' value='" . htmlspecialchars($field['Code']) . "' required> </div> <div class='col'> <input type='text' class='form-control w-100' name='label[]' value='" . htmlspecialchars($field['Label']) . "' required> </div> <div class='col'> <input type='number' class='form-control w-100' name='width[]' min='1' max='12' value='" . htmlspecialchars($field['Width']) . "' required> </div> <div class='col'> ` + <?php echo (showDataClassifications($pdo, 'select', $field['Classification'])) ?> + ` </div> <div class='col'> <select class='form-select' name='type[]' required disabled> <option disabled selected value='0'>Please Select</option> " . getFieldTypes($pdo, $field['Type']) . " </select> </div> <div class='col-1 text-center'> <i class='fa-solid fa-ban'></i> </div> </div>` $('.fieldContainer').append($html) }) What is the correct way to get the php in this to execute after it is appended? Quote Link to comment https://forums.phpfreaks.com/topic/320185-output-php-function-in-js-output/ Share on other sites More sharing options...
Solution Adamhumbug Posted April 29 Author Solution Share Posted April 29 I am sorry all, i am having a bad month. Below is the answer $(document).on('click', '#newFieldRow', function() { console.log('clicked') $html = `<div class='row mb-3'> <div class='col'> <input type='text' class='form-control w-100' name='code[]' required> </div> <div class='col'> <input type='text' class='form-control w-100' name='label[]' required> </div> <div class='col'> <input type='number' class='form-control w-100' name='width[]' min='1' max='12' required> </div> <div class='col'> <?= showDataClassifications($pdo, 'select') ?> </div> <div class='col'> <select class='form-select' name='type[]' required > <option disabled selected value='0'>Please Select</option> <?= getFieldTypes($pdo, $field['Type']) ?> </select> </div> <div class='col-1 text-center'> <i class='fa-solid fa-ban'></i> </div> </div>` $('.fieldContainer').append($html) }) Quote Link to comment https://forums.phpfreaks.com/topic/320185-output-php-function-in-js-output/#findComment-1622662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.