Jump to content

[SOLVED] passing javascript variable or array to php? how?


kucing

Recommended Posts

Dear friends,

 

I have search google and tested many examples I found but non of them work for me..

So now I need your help to solve this thing..

 

Actually what I wanted to do was save some variables from javascript to my database but when doing that I don't want my page to refreash and also don't want any button asking me to submit then save!

 

Any thing will be best which do it automaticaly without clicking anywhere :)

 

Here is my code example.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Java2php Test</title>

</head>
<body>

<script type="text/javascript">
	var N=5;
	var array = new Array()
	var items = list.getElementsByTagName("li")

	for (var i = 0, n = N; i < n; i++) {
		var item = items[i]
		array.push(myFnc(item))
	}
	alert(array); // [b]<----- i want this array to forward to my php script[/b]
	return array.join('|')
</script>

<ul id="menu">
<li class="box" id=1>TEST1</li>
<li class="box" id=2>TEST2</li>
<li class="box" id=3>TEST3</li>
<li class="box" id=4>TEST4</li>
<li class="box" id=5>TEST5</li>
<li class="box" id=6>TEST6</li>
<li class="box" id=7>TEST7</li>
<li class="box" id=8>TEST8</li>
<li class="box" id=9>TEST9</li>
<li class="box" id=10>TEST10</li>
</ul>

</body>
</html>

 

Thanks

I appreciate your help.

K

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.