473,378 Members | 1,354 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,378 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 2460
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...

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.