473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

conversion of java script variable in to php

sanjay123456
125 100+
dear friends

I want to convert a java script variable in to php varible

some code i write its not work

<form name="myform" method="post" action="abc.php">
<input type="button" name="next_que" VALUE="next" onClick="incr(this.form)">
</form>


<SCRIPT LANGUAGE="JavaScript">
function incr(form){
static var next_que=1;
next_que++;
document.writeln(next_que);
window.location.href = "http://localhost/abc.php?next_que=" +next_que;
}
</SCRIPT>


?php
echo "<h1>Screen Resolution:</h1>";
echo "ghWidth : ".$_POST['next_que']."<br>";
?>


sanjay
Oct 27 '06 #1
9 2462
ronverdonk
4,258 Expert 4TB
Before you post in this forum READ THE POSTING GUIDELINES. IN YOUR CASE ESPECIALLY THE USE OF TAGS AROUND YOUR CODE!!
You post a GET variable in JS, so your code must be
[php]echo "ghWidth : ".$_GET['next_que']."<br>";[/php]

Ronald :cool:
Oct 27 '06 #2
sanjay123456
125 100+
Sir

i am were try it but not work .

plz tell me solution

sanjay
Oct 28 '06 #3
ronverdonk
4,258 Expert 4TB
Your var cannot be declared static, so
Expand|Select|Wrap|Line Numbers
  1. var next_que=1;
  2.  
Ronald :cool:
Oct 28 '06 #4
sanjay123456
125 100+
Dear Sir,

Thank you problem is solved .

but java script have no STATIC AND CONSTANT VARIABLE
then STATIC VAR next_que =1; statement not work.

Is there r any other method that whenever onclick event is occure
then next_que variable value is increment

sanjay
Oct 28 '06 #5
sanjay123456
125 100+
Sir
I think another way are following .......
whenever we click next then next variable is increment by one
but in this code some problem i am try to solve it .
if anyone solve it then send on maling list.



<form name="myform" method="post" action="abc.php">
<input type="button" VALUE="next" onClick="incr(this.form)">
</form>



<SCRIPT LANGUAGE="JavaScript">
function incr(form){
window.location.href = "http://localhost/abc.php";
}
</SCRIPT>

<?php
static $next=0;
$next +=1;

?>

sanjay
Oct 28 '06 #6
ronverdonk
4,258 Expert 4TB
I have no idea what you want to accomplish with this code. If the last part of your code (the PHP part) is the ABC.PHP then it won't work because you reload a fresh copy of ABC.PHP each time you call it from Javascript and each time the variable is declared and set to 1.

Maybe there is another way, but explain what you want to accomplish with your code.

And as I told you in the first reply: enclose your code within code or php or html tags. Read the Posting Guidelines before you post again!

Ronald :cool:
Oct 28 '06 #7
sanjay123456
125 100+
Sir
I want to make a online test paper .in this user click next button then
new question will be come from database
For this when ever onclick event is occure then php $next variable increment
by one and next question will come from database

sanjay
Oct 29 '06 #8
ronverdonk
4,258 Expert 4TB
I explicitely requested you to read the Posting Guidelines before you post again.Now we see that you double posted this question in this same forum!! If you keep doing that, I will remove both posts. For now I removed the double post.

Here is an example of what you intend to accomplish. This sample does not use JavaScript because you'll have a problem when JS is turned off in the browser of the student. In this sample the number is stored in the count entry of the $_SESSION array, so it is available each time. Try it out and see what you can do with it. Good luck.
[php]<?php
session_start();
if (!isset($_SESSION['count']))
$_SESSION['count'] = 1;
if (isset($_POST['submitted'])) {
//
// Do the select of the question from database
// and the display of the question here
//
echo 'This is question no. '.$_SESSION['count'];
//
$_SESSION['count'] += 1;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Questionnaire</title></head>
<body>
<form name="myform" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" VALUE="Click here for question <?php echo $_SESSION['count']; ?>" />
<input type="hidden" name="submitted" value="1" />
</form></body></html>[/php]
Ronald :cool:
Oct 29 '06 #9
sanjay123456
125 100+
Sir
You send me following message

I explicitely requested you to read the Posting Guidelines before you post again.Now we see that you double posted this question in this same forum!! If you keep doing that, I will remove both posts. For now I removed the double post.



tell me sir that where i get editor where i wirte the code and mailing list


i dont understand




sanjay
Oct 30 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andy R. | last post by:
Hello everyone, I've spent quite some time now, looking for some information on how to get this done, sadly none has helped me much, though. I have a bit of java scrpt on a webpage (.php) to...
6
by: Johan Louwers | last post by:
I have a qustion. I have to set a JAVA_HOME variable on a Solaris9 system... what kind of a variable? A system-defined.../....a user defined.../.....???? and how do I set this so java can...
3
by: StealthMonkey | last post by:
Let me prefix this by saying that I know next to nothing about Java (so please try to keep explainations simple). I use PHP for my server-side web programming. Here is my dilemma: I need a...
4
by: Laura P | last post by:
Hi, I wasn't sure whether this should be posted in the Java are or in a Solaris thread, so I shall post it in both. Sorry for the duplication. I am new to Solaris and am having trouble...
4
by: Don Grover | last post by:
I hope some one can help, I have a html table that is created with asp that has a row of repeated buttons down the side. these call a page passing a query string with invoice number. I need to...
2
by: ckerns | last post by:
I have a recordset (ADO) that I loop thru in ASP. How can I also assign these values to a java variable? tia ck
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
9
by: Stephen H. | last post by:
Hi, I have an existing web application with java beans that I wanne migrate to ASP.NET using C#. The existing web application has some jsp files that use java beans as follows: .... <%@...
0
by: maheshmohta | last post by:
Background Often while remodeling legacy application, one of the important tasks for the architects is to have an optimum usage of storage capabilities of database. Most of the legacy applications...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.