#1
  1. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Location
    Brisbane, Australia
    Posts
    1,442
    Rep Power
    29

    Setting a request parameter in javascript


    I'm wondering if it is possible to create and set a request parameter from javascript.

    I am using the following functions to get and set the scrollvalue of a page.

    Code:
    function GetScrollValue() 
    {
    	if (document.documentElement && document.documentElement.scrollTop)
    		scrollValue = document.documentElement.scrollTop;
    	else if (document.body)
    		scrollValue = document.body.scrollTop;
    	else
    		scrollValue = window.pageYOffset;
    	return (scrollValue);
    }
    
    function SetScrollValue(scrollValue)
    {
    	if (document.documentElement && document.documentElement.scrollTop)
    		document.documentElement.scrollTop = scrollValue;
    	else if (document.body)
    		document.body.scrollTop = scrollValue;
    	else
    		window.pageYOffset = scrollValue;
    }
    However it would be much nicer if the first function could set a request parameter and the 2nd function could look for that parameter and set the scroll value if the parameter exists.

    Can this be done??
  2. #2
  3. No Profile Picture
    Perl Ronin
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    152
    Rep Power
    13
    its difficult to answer properly without knowing how you are calling these functions, and when. I'll take a stab in the semi-dark:

    you could set a global variable, then populate it in the function, then use it in the second function. ie:

    Code:
    <SCRIPT>
    
    var globalScrollValue = '';
    
    function first() {
    
      globalScrollValue = 75;
    }
    
    function second() {
    
      if(globalScrollValue != '') {
     
                                   [ .. do something here with globalScrollValue ... ]
                                             }
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Location
    Brisbane, Australia
    Posts
    1,442
    Rep Power
    29
    close but no donut, the problem is that the get scroll function will need to get the scroll value from the request, and the set scroll function will need to add a paramater to the form. (something along the lines of <input type='hidden' name='scrollValue' value='myScrollValue'>)

IMN logo majestic logo threadwatch logo seochat tools logo