Jump to content

Javascript variables to php-mysql


dannybrazil

Recommended Posts

Hello

Im using javascript and cookies to send to another page in my site some variables

 

In the other page i recieve them like that :

<script language="JavaScript"> 
if (widget_array != ""){
for (i=1; i < widget_array.length; i++){
document.write("<h3>" + widget_array[i] + "</h3>");
}//ends diplay FOR
}//ends widget display

if(ninja_array != ""){
for (i=1; i < ninja_array.length; i++){
document.write("<h3>" + ninja_array[i] + "</h3>");
}//ends FOR
}//ends ninja display
</script> 

 

Now my question is ....(and this is the php - sql question)

how can i make the variable the i passed to stay a variable , e.g.

 

variable page 1:

id=123

*i entered the number 123 into the cookie

variable page 2:

now this page will show me ALL the array ( 123...134...156...etc...)

but i dont want it to print it on the screen i just want to get variables that i can use php-mysql

e.g. $id=123

in order to print the specific data from my data base

 

hope u got it....

 

Danny

Link to comment
Share on other sites

use a hidden input and use a document.GetElementById('hidden').value = javascriptVar;

(use "hidden" as the inputs name attribute)

then use:

document.forms('id').submit;

to submit it (make sure the forms method="POST")

then to access it via the new page is $_POST['hidden']

then do whatever you want with the php var with SQL.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.