I am trying to set the ID as a variable, how can i?
<?php
$counter = 1;
$i = 1;
$testvar[$i] = ("NUMBER" + $i);
?>
<input type="button" id="<?php echo($testvar[$i]); ?>"/>
<script>
var btn['<?php echo($i); ?>'] = document.getElementById("<?php echo($testvar[$i]); ?>");
btn.onclick = CreateButton;
function CreateButton(){
<?php
$counter++;
while ($i < $counter){
i++;
echo("<input type='button' id='<?php echo($testvar[$i]); ?>'/>");
}
?>
};
</script>
The ID is not being reconigzed as a variable
You forgot to add the $
to one of our variables:
<?php
$counter++;
while ($i < $counter){
$i++; //Missing $
echo("<input type='button' id='<?php echo($testvar[$i]); ?>'/>");
}
?>
And as a sidenote, your question is really unclear. You should describe better what is not working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.