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 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ok, I have two forms in seperate html files, but i want one value from.....

    ....form 1 to be carried into form 2.

    say i have:
    <form action="page2.html" method="get/post">
    <input type="text" value="patrick" name="name">
    </form>

    in form one. Now what i want is the value "name" to be carried from this form into a hidden input field in a form on page 2.

    How do i do this?

    thanks in advance

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im not sure if that could be done using javascript.. I would suggest using a server side language such as perl or asp.
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Give this a try
    Code:
    <script>
    function QueryString(key)
    {
    	var value = null;
    	for (var i=0;i<QueryString.keys.length;i++)
    	{
    		if (QueryString.keys[i]==key)
    		{
    			value = QueryString.values[i];
    			break;
    		}
    	}
    	return value;
    }
    QueryString.keys = new Array();
    QueryString.values = new Array();
    
    function QueryString_Parse()
    {
    	var query = window.location.search.substring(1);
    	var pairs = query.split("&");
    	
    	for (var i=0;i<pairs.length;i++)
    	{
    		var pos = pairs[i].indexOf('=');
    		if (pos >= 0)
    		{
    			var argname = pairs[i].substring(0,pos);
    			var value = pairs[i].substring(pos+1);
    			QueryString.keys[QueryString.keys.length] = argname;
    			QueryString.values[QueryString.values.length] = value;		
    		}
    	}
    
    }
    
    QueryString_Parse();
    </script>
    You'd have to use method="get" on your form

  • #4
    New Coder
    Join Date
    Dec 2002
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can't you just set the cookies to set it i made something like that in perl tho
    Last edited by Xphp->UG-S<-; 12-21-2002 at 06:23 PM.
    print="TO Ask Will Unmask The Obvious-Jose 2002";

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cookies way:
    Code:
    <script type="text/javascript" language="javascript">
    function strCook() {
    document.cookie = escape(document.forms[0].test.value);
    }
    </script>
    <input type="text" value="" name="test">
    <input type="button" value="store cookie" onClick="strCook()">
    and on the other page
    Code:
    <script type="text/javascript">
    setTimeOut("document.forms[0].test0.value = unescape(document.cookie);
    </script>
    <input type="text" value="" name="test0">


  •  

    Posting Permissions

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