Running shortcode with variable that is modified

I am a newbie to wordpress … please help … cannot get this code to work … the [datatable} shortcode is a plugin shortcode (so it does exist)

Worpress page:

<label>Client ID Nr</label> <input id=”clientidnr” name=”clientidnr” placeholder=”9999″ type=”text”> <input type=”button” style=”background-color:#6D4053;color:white;” onclick=”customidnr(0, ‘shortc’)” name=”submit” value=”Submit” />


function customidnr(idnr, sc) {
var input;
if (idnr !== undefined && idnr !== 0) {
input = idnr;
} else {
input = document.getElementById(“clientidnr”).value;

var data = {
‘action’: ‘custom_id_nr’,
‘idnr’: input
};“/wp-admin/admin-ajax.php”, data, function(response) {
// whatever you need to do; maybe nothing


THEME – functions.php

add_action( ‘wp_ajax_nopriv_custom_id_nr’, ‘custom_id_nr’ );
add_action( ‘wp_ajax_custom_id_nr’, ‘custom_id_nr’ );
function custom_id_nr() {
$idnr = intval( $_POST[‘idnr’] );
echo do_shortcode(‘[datatable id=30 var1=”.$idnr.”]’);

Read more here:: Running shortcode with variable that is modified

Leave a Reply

Your email address will not be published. Required fields are marked *