I’m no PHP guru but I believe this is possible, looking for some direction how to do so. Imagine a simple box displayed on a page made up of a simple <div> tag, styled using CSS using the properties: width, height, border, background-color. Also on the page would be HTML form text fields for each CSS property. If a user would enter a width of 300px and hit an update button, the sample box would resize to display with that dimension. They user could enter different data for each CSS property and hit an update button, the the sample box would display using the inputted data.
Does anyone know how to go about doing this or maybe some examples of something similar?
You don’t even need PHP to do this (unless you want to somehow remember what users typed in).
For real time changes javascript (or a javascript framework like jQuery) should suffice. That also saves you server requests and thus resources and data traffic.
I thought it might also be doable in Javascript, but I do need to do it in PHP. Anyone know how this might be done?
An (extremly simple) example would be:
<?php
$width = isset($_POST['width']) && ctype_digit($_POST['width']) ? $_POST['width'] : 300;
?>
<div style="width: <?php echo $width; ?>px;">
<form method="post" action="">
<input type="text" name="width" value="<?php echo $width; ?>" />
<input type="submit" value="Go!" />
</form>
</div>