Question:

How to set value to global variable in javascript from html.?

by  |  earlier

0 LIKES UnLike

I have html page that takes input from user in textbox and when user clicks on "Connect" javascript is called and value is passed for system to connect, i am able to send the value to that function but cant use that value for any other function in that script, so i want to pass it to global vaiable so that it is accesible for the whole script.

 Tags:

   Report

1 ANSWERS


  1. Have you tried to declare the variable outside the function?

    var outside = null;

    function setoutside(value)

    {

    outside = value;

    }

    From your html page, you can now call <script>setouside('newvalue');</script>

    The global value will now be 'newvalue', and can be used by other functions.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.