i cant figure out how to use one script function for more id's. for just one id it works well, but if i activate the secound
include('scripts/js/js_dynamisches_textdarstellung.php');
the array text is splited over both ID's. i know the code is disgusting atm, but it's my first try to understand how it works and it's nice to see the different forms how i could set the variables from php to javascript. the problem what i see is, that the function has all the time the same name but i don't find a solution how to solve that. thx for help
main.php
<a href="#" target="_blank" id="dyn_Loop_main_v1">Bla to TEXT 1</a></li>
<?php
$var_anzahl_i_php = 0;
$name_der_funktion = "thats_it_1";
$var_reaktionszeit_in_ms_php = 1500;
$var_id_php = "dyn_Loop_main_v1";
$var_array_php = array("TEXT for ID_1_1",
"TEXT for ID_1_2",
"TEXT for ID_1_3",
"TEXT for ID_1_4");
$var_count_array = count($var_array_php);
print "<script type='text/javascript'> var var_array_inhalt = ".json_encode($var_array_php)."; </script>";
//print "<script type='text/javascript'> var var_funktionsname = ".json_encode($name_der_funktion).$name_der_funktion."; </script>";
include('scripts/js/js_dynamisches_textdarstellung.php');
?>
<a href="#" target="_blank" id="dyn_Loop_main_v2">Bla to Text 2</a></li>
<?php
$var_anzahl_i_php = 0;
$name_der_funktion = "thats_it_2";
$var_reaktionszeit_in_ms_php = 1000;
$var_id_php = "dyn_Loop_main_v2";
$var_array_php = array("TEXT for ID_2_1",
"TEXT for ID_2_2",
"TEXT for ID_2_3",
"TEXT for ID_2_4");
$var_count_array = count($var_array_php);
print "<script type='text/javascript'> var var_array_inhalt = ".json_encode($var_array_php)."; </script>";
//print "<script type='text/javascript'> var var_funktionsname = ".json_encode($name_der_funktion).$name_der_funktion."; </script>";
include('scripts/js/js_dynamisches_textdarstellung.php');
?>
js_dynamisches_textdarstellung.php
<script>
var var_anzahl_i = "<?php echo $var_anzahl_i_php ?>";
var var_i_from_count_i = "<?php echo $var_count_array ?>";
var var_ms_from_count_i = "<?php echo $var_reaktionszeit_in_ms_php ?>";
function var_funktionsname() {
setTimeout(function () {
document.getElementById('<?php echo $var_id_php ?>').innerHTML = var_array_inhalt[var_anzahl_i];
var_anzahl_i++;
if ( var_anzahl_i == var_i_from_count_i ) { var_anzahl_i = 0}
if ( var_anzahl_i < var_i_from_count_i + +1) {
var_funktionsname();
}
}, var_ms_from_count_i)
}
var_funktionsname();
</script>