I have a multiple character search field which fetches WoocCommerce product data via AJAX and works correctly.
Current search field
I need to split my search field into single 6 digit boxes, this is an example of the form I could use:
<form>
<input type="number" name="abc" min="0" max="9">
<input type="number" name="abc" min="0" max="9">
<input type="number" name="abc" min="0" max="9">
<input type="number" name="abc" min="0" max="9">
<input type="number" name="abc" min="0" max="9">
<input type="number" name="abc" min="0" max="9">
</form>
How can I split the string of my search field into multiple single digit search fields?
My Front End Code
<input type="text" name="keyword" id="keyword" onkeyup="fetch()">
<div id="datafetch">Your numbers will show here</div>
<script>
function fetch(){
$.post('<?php echo admin_url('admin-ajax.php'); ?>',
{'action':'my_action'},
function(response){
$('#datafetch').append(response);
console.log(result);
});
}
</script>
Code in Functions.php
add_action('wp_ajax_data_fetch' , 'data_fetch');
add_action('wp_ajax_nopriv_data_fetch','data_fetch');
function data_fetch(){
$myquery = esc_attr( $_POST['keyword'] );
}

