简体   繁体   中英

Javascript : changing text into paragraph tags

I'm trying to change the text inside a paragraph tag like so :

    <script>
    function select()
                        {
                           if (document.getElementById("lan").value=="Français")
                              {
                                 document.getElementById("txt1").text="Veuillez entrer votre adresse mail et cliquer sur le bouton ci-dessous.";
                                 document.getElementById("txt2").text="Consultez ensuite votre boîte mail.";
                              }

                           else {
                                 document.getElementById("txt1").text="Enter your e-mail address and click on the button below";
                                 document.getElementById("txt2").text="Then check your mail box";
                              }
                        }
        </script>
<p id="txt1">Veuillez entrer votre adresse mail et cliquer sur le bouton ci-dessous.</p>
<p id="txt2">Consultez ensuite votre boîte mail.</p>

The event taken is from a select tag like so :

<select id="lan" name=lan onchange="select()" type=submit>
      <option value="Français" selected>Français</option>
      <option value="English">English</option>
</select>

The script above works perfectly when I'm changing text values for input tags, but for paragraph tags, it doesn't work... I probably forgot something... Thanks for helping !

Change it to:

<script>
    function select()
                        {
                           if (document.getElementById("lan").value=="Français")
                              {
                                 document.getElementById("txt1").innerHTML="Veuillez entrer votre adresse mail et cliquer sur le bouton ci-dessous.";
                                 document.getElementById("txt2").innerHTML="Consultez ensuite votre boîte mail.";
                              }

                           else {
                                 document.getElementById("txt1").innerHTML="Enter your e-mail address and click on the button below";
                                 document.getElementById("txt2").innerHTML="Then check your mail box";
                              }
                        }
        </script>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM