473,378 Members | 1,162 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.

Pass variable into PHP via JAax

1
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include('header.php'); 
  3.         require_once('/homepages/9/d322999378/htdocs/spaincoastrealty/wordpress_en/wp-admin/includes/image.php');
  4.         require_once("/homepages/9/d322999378/htdocs/spaincoastrealty/wordpress_en/wp-load.php");
  5.         global $wpdb;
  6.         global $posts;
  7. ?> <form id = "test" method = "post"> <div> <div class="control-group"> <label class="control-label" for="selectError">Site</label> <div class="controls"> <select name="sitechooser" id="sitechooser"> <option value="Site1" selected>Site1</option> <option value="Site2">Site2</option> </select> </div> </div> </div> <input type = "text" id = "site_value" value = "some text"> </form> <script>
  8.         $(document).ready(function (e) {
  9.  
  10.                 $('#sitechooser').change(function () {
  11.                     var selected = $("#sitechooser option:selected").text();
  12.                     if (selected == "Site1") {
  13.  
  14.                         var id = $('#site_value').val();
  15.                         $.ajax({
  16.                                 url: 'try.php',
  17.                                 dataType: 'JSON',
  18.                                 data: {id: id},
  19.                                 success: function(data){
  20.                                     alert(data);
  21.                                     id = data.id;
  22.                                     $('#id').text(id);
  23.                             }
  24.                         });
  25.                     } 
  26.  
  27.                 });
  28.         });        
  29.         </script> <?php
  30.  
  31.         echo "id = ".$id;
  32.  
  33.         ?>
I want to get id value in php $id variable.

Is something wrong in my code? THanks
Nov 22 '14 #1
1 1324
Dormilich
8,658 Expert Mod 8TB
$_GET["id"] .
Nov 22 '14 #2

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

Similar topics

1
by: weiwei | last post by:
Hi all I am having trouble, let's say, I have a form text field, and I want to pass it to the next page, however, I don not want to use submitted button, instead I want to have a variable in link...
4
by: Wayne Baswell | last post by:
I want to pass a date variable to a sql statement from Crystal Reports. The part of the query accepting the variables looks like: "Calendar_Date between To_Date('1-JUN-03','mm/dd/yy') and...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
1
by: Ben Kial | last post by:
I'd like to write a wrapper function "mysprintf(char *buffer, char *format, ....)" which calls sprintf(). My question is how can I pass variable argument in mysprintf() to sprintf(). Thanks in...
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
1
by: dollar | last post by:
I want to ask what is the best way to pass variable between asp.net we pages, and user controls , any examples - dolla -----------------------------------------------------------------------...
1
by: drec | last post by:
I need to pass a variable from script1.php to script2.php. The problem is that these scripts use frames and therefore I am able to pass the variable through the URL. It also does not use forms to...
1
by: vijaynarang | last post by:
strCmdLine = " " + " -o restore -url " + sSitePath + "/sites/" + sToplevelSiteName + " -filename " + sFileName+ " -overwrite "; process1 =...
12
by: simon2x1 | last post by:
i have a page which is home.php on that page i have a CSS tab which is tab1 and tab2 on that page in both tabs i have a link called next that pass variable to the next page (<a...
2
by: peachdot | last post by:
hi, The MainForm will have 2 buttons: 1.) Button A : User click button A, hide Mainform then go to form1. User enter data in the textbox.Click finish button,form1 close then go back to...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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?
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...

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.