Basically i'm trying to write a previous next link in order to go to
the next page in my database(similar to google's with numbers in the
middle for pages the user wants to jump to.
My only thought is i'm losing the parameters on page reload.
But if that is the case then I don't know the correct technique to keep
the variables
I am programming in php but using a javscript function with onclick.
I could use $_SESSION variables to retain the values in the page but i
shouldn't have to do that should I?
Here is the code:
for ($i=0; $i <= $max_page_number; $i++)
{?>
<a href = 'http://localhost/local/restaurants.php'
onclick='nav(<?echo
$i.",".$max.",".$min.",".$page_results.",".$page_n umber;?>);'><?echo
$i;?> </a>
<?}
And Here is the function:
<script language = "JavaScript">
<!--
function nav(pointer, maxx, minn, page_results, page_number)
//sets the min and max limits
{
maxx= pointer * page_results;
minn= maxx - page_results;
page_number = pointer; //change page number
//document.writeln("Do you really want to follow this link?"+maxx+'::'+
minn+'::'+ page_results+'::'+ page_number);
}
//-->
</script>
As you can see i've commented out a document.writeln which displays the
variables on a web page and increments them accordingly.
but there is nothing else on the web page when i use it.
ANy help would be appreciated
b 1 1740 br********@yahoo.com wrote: [...] My only thought is i'm losing the parameters on page reload.
Of course. Global variables are properties of the global object, which
is recreated on reload as the client-side script engine is terminated prior.
But if that is the case then I don't know the correct technique to keep the variables
Sessions which require server-side programming, such as
I am programming in php but using a javscript function with onclick.
^^^ I could use $_SESSION variables to retain the values in the page but i shouldn't have to do that should I?
You should.
Here is the code:
for ($i=0; $i <= $max_page_number; $i++) {?> <a href = 'http://localhost/local/restaurants.php' onclick='nav(<?echo $i.",".$max.",".$min.",".$page_results.",".$page_n umber;?>);'><?echo $i;?> </a> <?}
Although I do understand PHP, other subscribers may not. We are not your
preprocessors, PHP is. So please use it and post what the client receives.
And Here is the function: <script language = "JavaScript"> <!--
Should read
<script type="text/javascript">
function nav(pointer, maxx, minn, page_results, page_number) //sets the min and max limits { maxx= pointer * page_results; minn= maxx - page_results; page_number = pointer; //change page number //document.writeln("Do you really want to follow this link?"+maxx+'::'+ minn+'::'+ page_results+'::'+ page_number); }
I don't see page_number defined elsewhere, so I have to assume it is only
a local variable. JS does support call-by-value only, so if the local
execution context is left, nothing has changed in the global context.
//--> </script>
That should read
</script>
As you can see i've commented out a document.writeln which displays the variables on a web page and increments them accordingly. but there is nothing else on the web page when i use it.
Unless the function is called when the document is loaded, you should not
use document.write(ln); it overwrites the content once the document has
loaded. In that case, you have to use methods introduced in the IE DOM
or W3C DOM Level 1.
PointedEars
--
Microsoft has been doing a really bad job on their OS. -- Linus Torvalds This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Derek Hart |
last post by:
I wish to execute code from a string. The string will have a function name,
which will return a string:
Dim a as string
a = "MyFunctionName(param1, param2)"
I have seen a ton of people...
|
by: Shock |
last post by:
Hello everyone,
I am having a problem with the program below. I have isolated the problem
to the onclick event that is located throughout arrQuestions. The onclick
event refers to a function...
|
by: Materialised |
last post by:
I am writing a simple function to initialise 3 variables to pesudo
random numbers.
I have a function which is as follows
int randomise( int x, int y, intz)
{
srand((unsigned)time(NULL));
x...
|
by: Adam Warner |
last post by:
Hello all,
I'm very new to C but I have a number of years of Common Lisp programming
experience. I'm trying to figure out ways of translating higher order
concepts such as closures into C. The...
|
by: None |
last post by:
Hello,
1.
The prototype of function signal in signal.h:
void (*signal(int sig, void (*func)(int)))(int);
is some complex to me. Would you please explain it to me in detail with
the C...
|
by: vijay.gandhi |
last post by:
Hello,
I have created a function in C++/CLI which was exported as a .DLL to
be used in VB .NET. I have been having some problems (I think it has
to do with the right syntax) with parameter...
|
by: SM |
last post by:
Hello,
I have two functions: show_thumbnail() and show_photo(). See code
below.
In show_thumbnail() i create a <ullist using Javascript and the DOM.
In the tag <ai create a onclick function and...
|
by: Sri Harsha Dandibhotla |
last post by:
Hello all.
I recently came across a function declaration as :
char(*(*x()))();
This was not in some code but it was in a C questions thread on some
group.
I tried to decipher what it returns but...
|
by: ctj951 |
last post by:
I have a very specific question about a language issue that I was
hoping to get an answer to. If you allocate a structure that
contains
an array as a local variable inside a function and return...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |