How to replace specified word of the Latin in other specified word using javascript?












0















I want to replace some word with another over javascript.



I find some code which I tried:



<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>


but I don't know coding and when I put this on the website I got the error in console:




Uncaught ReferenceError: $ is not defined











share|improve this question

























  • you are getting this error because u have not loaded the jquery

    – Amir shah
    Dec 31 '18 at 19:16






  • 2





    ^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

    – Taplar
    Dec 31 '18 at 19:17











  • use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

    – Amir shah
    Dec 31 '18 at 19:20











  • Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

    – Mikkel
    Dec 31 '18 at 22:54
















0















I want to replace some word with another over javascript.



I find some code which I tried:



<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>


but I don't know coding and when I put this on the website I got the error in console:




Uncaught ReferenceError: $ is not defined











share|improve this question

























  • you are getting this error because u have not loaded the jquery

    – Amir shah
    Dec 31 '18 at 19:16






  • 2





    ^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

    – Taplar
    Dec 31 '18 at 19:17











  • use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

    – Amir shah
    Dec 31 '18 at 19:20











  • Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

    – Mikkel
    Dec 31 '18 at 22:54














0












0








0








I want to replace some word with another over javascript.



I find some code which I tried:



<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>


but I don't know coding and when I put this on the website I got the error in console:




Uncaught ReferenceError: $ is not defined











share|improve this question
















I want to replace some word with another over javascript.



I find some code which I tried:



<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>


but I don't know coding and when I put this on the website I got the error in console:




Uncaught ReferenceError: $ is not defined








javascript html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 12:53









user5377037

7,430122661




7,430122661










asked Dec 31 '18 at 19:14









MarkMark

55




55













  • you are getting this error because u have not loaded the jquery

    – Amir shah
    Dec 31 '18 at 19:16






  • 2





    ^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

    – Taplar
    Dec 31 '18 at 19:17











  • use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

    – Amir shah
    Dec 31 '18 at 19:20











  • Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

    – Mikkel
    Dec 31 '18 at 22:54



















  • you are getting this error because u have not loaded the jquery

    – Amir shah
    Dec 31 '18 at 19:16






  • 2





    ^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

    – Taplar
    Dec 31 '18 at 19:17











  • use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

    – Amir shah
    Dec 31 '18 at 19:20











  • Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

    – Mikkel
    Dec 31 '18 at 22:54

















you are getting this error because u have not loaded the jquery

– Amir shah
Dec 31 '18 at 19:16





you are getting this error because u have not loaded the jquery

– Amir shah
Dec 31 '18 at 19:16




2




2





^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

– Taplar
Dec 31 '18 at 19:17





^^^ Also str_replace is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue

– Taplar
Dec 31 '18 at 19:17













use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

– Amir shah
Dec 31 '18 at 19:20





use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");

– Amir shah
Dec 31 '18 at 19:20













Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

– Mikkel
Dec 31 '18 at 22:54





Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)

– Mikkel
Dec 31 '18 at 22:54












3 Answers
3






active

oldest

votes


















0














you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js






share|improve this answer
























  • Now i get this error Uncaught ReferenceError: jQuery is not defined?

    – Mark
    Dec 31 '18 at 19:20











  • are you using the code without the <script> tag?

    – Amir shah
    Dec 31 '18 at 19:22











  • no, i put the <script> tag

    – Mark
    Dec 31 '18 at 19:23











  • use without the <script> tag.

    – Amir shah
    Dec 31 '18 at 19:28



















0














codes you use in php code






<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>








share|improve this answer
























  • he is asking for the jquery or javascript code to be placed in the console not for the php code.

    – Amir shah
    Dec 31 '18 at 19:36



















0

















var str = 'ščđ';

var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});

console.log(str);








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990729%2fhow-to-replace-specified-word-of-the-latin-in-other-specified-word-using-javascr%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
    https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js






    share|improve this answer
























    • Now i get this error Uncaught ReferenceError: jQuery is not defined?

      – Mark
      Dec 31 '18 at 19:20











    • are you using the code without the <script> tag?

      – Amir shah
      Dec 31 '18 at 19:22











    • no, i put the <script> tag

      – Mark
      Dec 31 '18 at 19:23











    • use without the <script> tag.

      – Amir shah
      Dec 31 '18 at 19:28
















    0














    you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
    https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js






    share|improve this answer
























    • Now i get this error Uncaught ReferenceError: jQuery is not defined?

      – Mark
      Dec 31 '18 at 19:20











    • are you using the code without the <script> tag?

      – Amir shah
      Dec 31 '18 at 19:22











    • no, i put the <script> tag

      – Mark
      Dec 31 '18 at 19:23











    • use without the <script> tag.

      – Amir shah
      Dec 31 '18 at 19:28














    0












    0








    0







    you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
    https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js






    share|improve this answer













    you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
    https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 31 '18 at 19:17









    Amir shahAmir shah

    1066




    1066













    • Now i get this error Uncaught ReferenceError: jQuery is not defined?

      – Mark
      Dec 31 '18 at 19:20











    • are you using the code without the <script> tag?

      – Amir shah
      Dec 31 '18 at 19:22











    • no, i put the <script> tag

      – Mark
      Dec 31 '18 at 19:23











    • use without the <script> tag.

      – Amir shah
      Dec 31 '18 at 19:28



















    • Now i get this error Uncaught ReferenceError: jQuery is not defined?

      – Mark
      Dec 31 '18 at 19:20











    • are you using the code without the <script> tag?

      – Amir shah
      Dec 31 '18 at 19:22











    • no, i put the <script> tag

      – Mark
      Dec 31 '18 at 19:23











    • use without the <script> tag.

      – Amir shah
      Dec 31 '18 at 19:28

















    Now i get this error Uncaught ReferenceError: jQuery is not defined?

    – Mark
    Dec 31 '18 at 19:20





    Now i get this error Uncaught ReferenceError: jQuery is not defined?

    – Mark
    Dec 31 '18 at 19:20













    are you using the code without the <script> tag?

    – Amir shah
    Dec 31 '18 at 19:22





    are you using the code without the <script> tag?

    – Amir shah
    Dec 31 '18 at 19:22













    no, i put the <script> tag

    – Mark
    Dec 31 '18 at 19:23





    no, i put the <script> tag

    – Mark
    Dec 31 '18 at 19:23













    use without the <script> tag.

    – Amir shah
    Dec 31 '18 at 19:28





    use without the <script> tag.

    – Amir shah
    Dec 31 '18 at 19:28













    0














    codes you use in php code






    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>








    share|improve this answer
























    • he is asking for the jquery or javascript code to be placed in the console not for the php code.

      – Amir shah
      Dec 31 '18 at 19:36
















    0














    codes you use in php code






    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>








    share|improve this answer
























    • he is asking for the jquery or javascript code to be placed in the console not for the php code.

      – Amir shah
      Dec 31 '18 at 19:36














    0












    0








    0







    codes you use in php code






    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>








    share|improve this answer













    codes you use in php code






    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>








    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>





    <?php
    $text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
    $search = array('š', 'č', 'đ', 'ć', 'ž');
    $replace = array('s', 'c', 'dj', 'c', 'z');
    $string = str_replace($search, $replace, $text);
    echo $string;
    ?>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 31 '18 at 19:31









    Doğan KılınçDoğan Kılınç

    1




    1













    • he is asking for the jquery or javascript code to be placed in the console not for the php code.

      – Amir shah
      Dec 31 '18 at 19:36



















    • he is asking for the jquery or javascript code to be placed in the console not for the php code.

      – Amir shah
      Dec 31 '18 at 19:36

















    he is asking for the jquery or javascript code to be placed in the console not for the php code.

    – Amir shah
    Dec 31 '18 at 19:36





    he is asking for the jquery or javascript code to be placed in the console not for the php code.

    – Amir shah
    Dec 31 '18 at 19:36











    0

















    var str = 'ščđ';

    var mapObj = {
    š:"s",
    đ:"dj",
    č:"c"
    };
    str = str.replace(/š|đ|č/gi, function(matched){
    return mapObj[matched];
    });

    console.log(str);








    share|improve this answer




























      0

















      var str = 'ščđ';

      var mapObj = {
      š:"s",
      đ:"dj",
      č:"c"
      };
      str = str.replace(/š|đ|č/gi, function(matched){
      return mapObj[matched];
      });

      console.log(str);








      share|improve this answer


























        0












        0








        0










        var str = 'ščđ';

        var mapObj = {
        š:"s",
        đ:"dj",
        č:"c"
        };
        str = str.replace(/š|đ|č/gi, function(matched){
        return mapObj[matched];
        });

        console.log(str);








        share|improve this answer
















        var str = 'ščđ';

        var mapObj = {
        š:"s",
        đ:"dj",
        č:"c"
        };
        str = str.replace(/š|đ|č/gi, function(matched){
        return mapObj[matched];
        });

        console.log(str);








        var str = 'ščđ';

        var mapObj = {
        š:"s",
        đ:"dj",
        č:"c"
        };
        str = str.replace(/š|đ|č/gi, function(matched){
        return mapObj[matched];
        });

        console.log(str);





        var str = 'ščđ';

        var mapObj = {
        š:"s",
        đ:"dj",
        č:"c"
        };
        str = str.replace(/š|đ|č/gi, function(matched){
        return mapObj[matched];
        });

        console.log(str);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 31 '18 at 19:56









        JoshJosh

        7019




        7019






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990729%2fhow-to-replace-specified-word-of-the-latin-in-other-specified-word-using-javascr%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith