Is there a way to have javascript create php code, to be executed when it runs on the php page? I'm trying to set the value of an input to , where div_id is a js variable, and inputs is a 2D associative array.
The problem is that it literally sets the value to "" instead of the value of the floor_type field. Everything else seems to work.
inputs_div.innerHTML += `<div id="`+div_id+`" class="dynamic_div">
<ul class="dynamic_ul">
<li><input type="text" onblur="$('.save').click();" placeholder="Flooring Type: Wood Floor, Tile, etc." name="inputs[`+div_id+`][floor_type]" maxlength="255" value="<?php echo $_SESSION['inputs']['`+div_id+`']['floor_type']; ?>"></li>
</ul>
</div>
I'm creating some html inputs dynamically with javascript, but I'm looking for a way to prevent them from getting cleared if the page is refreshed. Maybe there is a simpler way to make the inputs stay there?
My idea was to use ajax to run some php code from the onblur event of each input element, which saves the inputs[][] array into the session, so it doesn't get lost when refreshing the page.