I need a little hand here!
<script>
window.onload = function() {
var oTextbox = document.getElementById('myTextBox');
for (var i = 0; i < document.oTextbox.length; i++) {
document.oTextbox[i].onfocus = function() {
oTextbox.value = this.alt;
};
for (var i = 0; i < document.images.length; i++) {
document.images[i].onclick = function() {
oTextbox.value = this.alt;
};
}
};
</script>
I got this script right here on the stack in script link , and use with one input and multiple images works perfectly! but when using the php script in foreach, it creates several inputs but all with the same name, I imagine that it is possible to click on or focus on the input and click on the image it can pass the values to another selected field! / p>
My foreach!
<?php foreach($data["category"] as $categ):?>
<label><?=$categ->name;?></label>
<input type="text" name="img_ent" id="myTextBox" value="Imagen entrada"
class="form-control" placeholder="Imagen Entrada">
<?php endforeach; ?>
Explaining better!
I got the script that I clicked on the image it automatically already puts the name of the image in the input ok, until then everything works fine, what I did was to make the input loop in foreach with php, that's okay too, he generates several inputs according to my database example 5 ... dae comes the problem when generating these 5 inputs I click on the image and it does exactly what it does without the loop, it only adds the text in the first input even though I click the second input it adds to the first one the same way! I thought I would do this on focus the other inputs because of clicking on the input and selecting by clicking on the image it passed the values to the other input. I can not imagine if it's possible ...