Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

kosackenzipfel on "Plugin/Widget Coding - document.getElementById doesn´t work"

$
0
0

Hello!

I have a problem creating a plugin/widget for wordpress. In the part of the code where the backend-form is created "document.getElementById" doesn´t work. I can read the fields of the form but I cannot change their value using JavaScript (Code below):

echo "<script type='text/javascript'>";
echo "function feld_aendern()";
echo "{";
echo " var alterwert = document.getElementById('tt11').value;";
echo " alert(alterwert);";
echo " var aenderung = document.getElementById('tt11');";
echo " aenderung.value = 'Neuer Wert';";
echo " alert('...wieder nicht geklappt?');";
echo "}";
echo "</script>";
echo "<p><input type='text' id='tt11' value='Alter Wert' onchange='feld_aendern()' /></p>";

The fields are generated by the .php - so why can I only read them (the 'alert' works), but not change their values? Must be something stupid I don´t see...
I also tried it excluding the JavaScript - with the same result...

// hier endet PHP ?>
<script type="text/javascript">
    function feld_aendern() {
        var alterwert = document.getElementById('tt11').value;
        alert(alterwert);
        var aenderung = document.getElementById('tt11');
        aenderung.value = 'Neuer Wert';
        alert('check?');
    }
</script>
<p><input type="text" id="tt11" value="Alter Wert" onchange="feld_aendern()"></p>
<?php // hier gehts weiter mit PHP

I would be very glad if I anyone could help me!!!


Viewing all articles
Browse latest Browse all 8245

Trending Articles