473,469 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

conversion of java script variable in to php

sanjay123456
125 New Member
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 2465
ronverdonk
4,258 Recognized Expert Specialist
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 New Member
Sir

i am were try it but not work .

plz tell me solution

sanjay
Oct 28 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
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 New Member
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 New Member
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 Recognized Expert Specialist
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 New Member
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 Recognized Expert Specialist
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 New Member
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.