Getting value GET OR POST variable using JavaScript?

前端 未结 9 1566
一个人的身影
一个人的身影 2020-11-27 05:59

How to get value of the get or post variable on page load using JavaScript?

9条回答
  •  离开以前
    2020-11-27 06:40

    This is my first Answer in stackoverflow and my english is not good. so I can't talk good about this problem:)

    I think you might need the following code to get the value of your or tags.

    this is what you might need:

    HTML

    
    
    

    JavaScript

    function checkvalue(input , Write) {
      var inputValue = document.getElementById(input).value;
      if(inputValue !="" && inputValue !=null) { 
        document.getElementById(Write).innerHTML = inputValue;
      } else { 
        document.getElementById(Write).innerHTML = "Value is empty";
      }
    }
    

    also, you can use other codes or other if in this function like this:

    function checkvalue(input , Write) {
      var inputValue = document.getElementById(input).value;
      if(inputValue !="" && inputValue !=null) { 
        document.getElementById(Write).innerHTML = inputValue;
        document.getElementById(Write).style.color = "#000";
      } else {
        document.getElementById(Write).innerHTML = "Value is empty";
      }
    }
    

    and you can use this function in your page by events like this:

    I hope my code will be useful for you

    Write by

提交回复
热议问题