Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    india
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    accessing the hidden variable from other file

    how to access the hidden variable stored in one file in the other html file. or how to access the parameters passed on perform some action in other html file
    phani

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Huh? A hidden variable? Can you be more specific? What are you trying to accomplish?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    perhaps he's talking about passing data through query strings

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that seems to make sense with the vocabulary he used. If that's the case, phani, you can use this function I wrote to extract all the GET parameters into an associative array
    Code:
    function parseGetVars() {
    	var getVars = new Array();
    	var qString = top.location.search.substring(1);
    	var pairs = qString.split("&");
    	var nameVal, val;
    	for (var i=0; i<pairs.length; i++) {
    		nameVal = pairs[i].split("=");
    		val = (typeof nameVal[1] == 'undefined') ? '' : unescape(nameVal[1]);
    		getVars[unescape(nameVal[0])] = val;
    		}
    	return getVars;
    	}
    var _GET = parseGetVars();
    Of course, you can use any variable you like, I just chose _GET because it closely mimics the PHP counterpart.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New Coder
    Join Date
    Aug 2002
    Location
    india
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML

    how to pass the parameters from one simple html page to another simple html page which is not having any relation between them....without having any server concept...
    can i get any sample application with code
    phani

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    if you don´t open the second page from the first one, use cookies. do a search in this forum for "cookies" it should return "some" results
    I am the luckiest man in the world

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    ...or use window.name if you are not using frames/iframes

    set it in a page:
    window.name="blah";


    you can access it in another page even if it is not opened from the page where you set the window.name:

    alert(window.name)
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    New Coder
    Join Date
    Aug 2002
    Location
    india
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    not getting the value of the hidden variable in the second html form

    Hi glenn i have two html pages like this but i am not getting the value of the hidden variable in the secod form..even we assign some name to the window here is my two html pages can u help me

    first html file (one.html)

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <script>
    window.name = "hello";
    alert(window.name)
    </script>
    <BODY BGCOLOR="#FFFFFF">
    <form action = "two.html">
    <input type="hidden" name = "vamsi" value = "hi">
    <input type="submit" name = "go" value = "Submit">
    </form>
    </BODY>
    </HTML>

    second html file (two.html)

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF">
    <script>
    alert(hello.doucment.forms[0].vamsi.value)
    </script>
    </BODY>
    </HTML>


    can i get that vamsi.value in the second html page...if so plzz let me know how it should be done...
    phani

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    in first page:

    <script>
    window.onload = function(){window.name=document.forms[0].vamsi.value};
    </script>
    <BODY BGCOLOR="#FFFFFF">
    <form action = "two.html">
    <input type="hidden" name = "vamsi" value = "hi">
    <input type="submit" name = "go" value = "Submit">
    </form>


    in second page:
    <script>
    alert(window.name)
    </script>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •