JQuery :: Post Checkbox As PHP Session Variables?
Apr 17, 2011
I have a php page (target_market.php), with a form that has 34 checkboxes. I would like the be able to click the boxes and have JS post the 'checked' value to a php session varibale when a button is clicked. If the user navigates away from the page and returns, the pages needs to reload the checkbox session variables.
How do I post the 'checked' value as either YES or NO using JS to another page (target_session.php), so that i can add them to database at a later stage?, but also retrieve the session variables and update the check boxes should the user come back to the target_market.php page?
View 9 Replies
ADVERTISEMENT
Nov 11, 2011
I have a little problem with saving a single checkbox state (check or uncheckd) for a session with jQuery.
I did find similar problems and solutions but i couldn't apply the help or solutions to my situation. So i give it a little try here..
Good to know is that I'm new to jQuery.
What i would like to achieve
I have one single checkbox that, when checked, will unhide some div's. When you uncheck the checkbox the div's will hide again. This is sort of an "Option". This works fine with the piece of jQuery code i have now.
The problem is that when a user checks the checkbox and then loads another page (/page2) the checkbox is unchecked again. I would like to store the checkbox state for a session. So users don't have to check the checkbox again, and again after browsing to the next page (if they wish to use this option).[code]...
View 2 Replies
View Related
Nov 29, 2009
I'm just beginning with JavaScript (and Ajax). My loginscript now works with Ajax - that is; the script is sending a request to the servers PHP script to check username and password, but I wonder what that script should return - and how to use that response. Either XML or pure text: The response is now "false" if the user couldn't log in for some reason, and the users ID and real name if the login went well...
But then the problem: if login IS ok - so that the users ID and real name is returned from the serverscript - I would like to store those variables in a session variable ($_SESSION in PHP). How do I get those variables back to the client script from JavaScript?
View 4 Replies
View Related
Jun 28, 2007
I had written code which created a shopping cart into an array using
vbscript and then transferred the information into a session
variable. However what I didn't know was that deleting/manipulating
information in an array using vbscript was not that easy.
In doing some reading and research it seemed that js was more flexible
in this area. My questions:
1) if I want to store cart items/details in an array and session
variable do I need to use only js (and can not switch back and forth
from vbscript and js)
2) if I have an array 6x12 and want to delete all the items
associated with say arrayItem[1, 0...12] what is the proper coding to
delete...is it splice?
3) any good articles about js, arrays, and multidimensional arrays
for a beginner?
View 3 Replies
View Related
Jan 21, 2009
How to pass (well more like bridge) session information to the client side from server side.
Right now, what I'm basically doing is echoing the userID and the username into a method in JavaScript tag at the bottom of every page.
The reason why I am doing this is simply for AJAX-related interactivity.
This is an example of what the code looks like:
Code:
A) It requires JavaScript code to be pasted within the HTML document (its non-external).
B) It requires the code to be echoed in EVERY PAGE.
C) A PHP Script or Class must maintain the responsibility of printing the session values.
D) The variable data cannot be accessed from any imported javascript files prior to where it was printed.
Now, I'm wondering about using Cookies. This would benefit me since I don't have to inject any ugly javascript code into the HTML output. I can also remove the PHP script that echoes the values and the changes will be purely handled in PHP (cookies can be updated!).
The only issue that's stopping me is simply security. Since cookies can be edited very easily on the client side, then the data can be changed. But then again so can the JavaScript (using a tool like Grease Monkey).
Once again, I am aware to never ever to trust the client side data without any validation; therefore using some sort of hash checksum, the cookie data can be compared to its PHP equivalents.
View 3 Replies
View Related
Aug 2, 2009
My knowledge of programming is very limited. I would like to calculate the average of session variables in Interpreted Java. However, some of session variables may not always be available. The first thing I do is remove the non numerical portion of the session variables:
String [] variables = {"A",'B','C','D','E'};
i = 0;
Iterate through each variable in the array above
while (i < variables.length){
Get the variables to be fixed
value = session.getVariable(variables[i]);
Log the UNFIXED values
session.log("UNFIXED: " + variables[i] + " = " + value);
if(value != null){
Remove non-numerical elements
value = value.replaceAll("\\D", "");
Set variables with new values
dataRecord.put(variables[i], value);
session.setVariable(variables[i], value);
Log the FIXED values
session.log("FIXED " + variables[i] + " = " + session.getVariable(variables[i]));
} i++;
}
Then I make sure the session variables can be treated as numbers:
A = Integer.parseInt(session.getVariable("A")).intValue();
B = Integer.parseInt(session.getVariable("B")).intValue();
C = Integer.parseInt(session.getVariable("C")).intValue();
D = Integer.parseInt(session.getVariable("D")).intValue();
E = Integer.parseInt(session.getVariable("E")).intValue();
Are they still alive?
session.log("A**" + A + "**");
session.log("B**" + B + "**");
session.log("C**" + C + "**");
session.log("D**" + D + "**");
session.log("E**" + E + "**");
I would like to calculate the average of A and B and save it as session variable AB, calculate the average of C and D and save it as session variable CD, and then the average of AB, CD, and E. Here's the weird part; AB, CD, and or E will not always be available. For example, AB will not be available so I need to calculate the average of CD and E or E will not be available so I need to calculate the average of AB and CD. As I said, my knowledge of programming is very limited so if you could provide code snippet with explanation of each step and where to plug in my session variables.
View 1 Replies
View Related
Oct 2, 2009
I have a div on my page that is populated by a php calendar. The calendar also has month and year input fields so that the user can browse to different months. I would like to create a jquery function so that, when a user changes the month or year field, the div reloads the calendar and passes the selected month and year variable back to the php script. Here is what I have on my page:
<head>
<script type="text/javascript">
function startCalendar(month, year) {
[code]....
View 1 Replies
View Related
Oct 22, 2010
I am wondering why:
$.post("remote.php",
{'f':a_searchtype, 'partial':value},
function(data){
$("#result").html(data);
[Code].....
causes javascript errors in unrelated sections of code.
The second version can be used in a common routine that doesn't know what is being passed.
View 1 Replies
View Related
Jun 12, 2010
I have acollection of local variables populated via Flash movies and scripts, and now I need to submit an ajax post (can also be get, but prefer post). I have tried:
$.ajax({
type: "POST",
url: "/myurl",
data: "p1=" + localParam1 + "&p2=" + localParam2,
success: function(msg){
alert( Bingo: " + msg );
}
});
The problem with this is the encoding of the localParam1 and localParam2 sometimes breaks the normal & delimeters. An even more problem is I sometimes haveupwards of 25+ local variables that I need to submit. These inline +s makes it feel, and look, like one huge hack - not to mention the encoding. One last restriction: I cannot use any jquery plugins due to the company's policy. So, I'm looking for something small and light as a solution - not a plug-in. Isn't there an easy way to do this? ONe thought I had was to create a new <form> on the page, and insert the variables as new <input /> fields - and then finally submit the entire form. Again, a big hack + css
View 2 Replies
View Related
Jan 29, 2007
I have something that runs on a server with no PHP or any of those widgets.
A user submits a form with 6 fields. Clicks "Go". A page appears that displays what he just entered, with a form of his data in hidden fields, and a link with document.form.submit() that takes you to a CGI program. It must be 2 different page loads.
Is displaying what he entered in the form in the next page possible with JavaScript? If so, what are the JS variables that would let me access that data?
View 3 Replies
View Related
Jun 11, 2007
Is there a way for delete variables of a form just before it is
sended to server?
I don't want to delete the input element, but only to prevent that
name/value to be sended to the server.
View 6 Replies
View Related
Feb 2, 2010
Alright, I'm trying to make these variables pass through as a post, but it's not receiving any posts through the other side. When I use the GET method though, it picks it up.
Code:
xmlhttp.open("POST","script.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(parameters);
[Code]...
View 3 Replies
View Related
Sep 3, 2010
There are different ways by which values of variables can be passed between forms. One of the ways is to use the setTimeout to pass the values or data. Here the biggest advantage is we can pass data to a different site even running automatically.I would need from someone a bit of help to pass the variable links from form1 to variable strLink in form2 using SetTimeout.We have the following schema:An options select menu where value of the option, sent with a submitted form, is specified with the value attribute. In the absence of a VALUE attribute, the value is the content of the option element.
<html>
<head>
</head>
[code]....
View 11 Replies
View Related
Nov 22, 2009
How can I send POST variables to a new window on form submit. I tried the below but what happens is the new window "foo.php" opens but no POST variables are present and also the parent page refreshes when I want it to remain static. Code:
<form method="POST" onsubmit="return validateStoreForm(this) && transferListValuesToCSV(document.theForm.box2) && window.open('foo.php', 'foo', 'width=450,height=300,status=yes,resizable=no,scrollbars=no')"; name="theForm" >
View 1 Replies
View Related
Jan 17, 2009
my url read index.html?pagego=collections
here it he code I have that is pulling the variables from the URL
function getUrlVars(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
[Code]....
and here is the code I use to alert
var hash = getUrlVars();
alert(hash['pagego']);
this works perfectly and alerts with the variable when I load he page.
Now when i am embedding my flash file i want to pass the variable to my flash by just adding the variable value to my embed code.
how can I do this?
here is my swf embed code
var so = new SWFObject("main2.swf?pagego="+THIS IS WHERE I WANT THE VARIABLE TO BE, "Preview", "100%", "100%", "9", "#ffffff", true);
so.addParam("scale", "noscale");
so.addParam("salign", "lt");
so.write("flashcontent");
View 1 Replies
View Related
May 4, 2011
how can I make ajax pass variables to php, I been trying to use $POST but it�s not working for me, I have this script
Code JavaScript:
function get_school_data()
{
var xmlhttp;[code]....
What I am trying to achieve is to send the value of country to php and have it stored in a variable so I can then select a different table in the database, but when I do it the way I am, it does not work, as it gives me an undefined variable
View 1 Replies
View Related
Oct 1, 2010
I have this code which allows a user to check multiple checkboxes by clicking just one check box. However, when I post the form, I only get the value of one check box. Suppose, I don't check the 'select all' check box and want to check only 1 and 3 checkbox, I still get the value for only one check box.
[Code]...
View 4 Replies
View Related
Jan 27, 2011
i retrieved data from mysql table into html page i.e
Code:
$query="select * from student";
$result=mysql_query($query)or die(mysql_error());
while($rs=mysql_fetch_array($result))
{
?>
[Code]...
assume that checkbox of id 1 is checked and retrieved from mysql table.<br /> Now what i want to do is that when i checked the remaing two checkbox into this table and a function is called to ajax which goes to php page and update the value of checked field according to the given id (i.e 2 and 3 in this case). Not refreshing the whole page nor updating the whole record just the value of check box.<br/> i am new to ajax so
View 6 Replies
View Related
Sep 11, 2009
A webpage has a number of questions that a user must answer and each question can be answered using a list of checkboxes. Thus each set of checkboxes (each question) will have a seperate name. The webpage is dynamically generated and I dont know how many questions will be on there nor the amount of checkboxes each question will have.
I know how to obtain the checkbox values using a form and a conventional submit button however what I want to do is put a button below each question and use AJAX to submit the answers for each question therefore the whole page will not refresh once each question is submitted.
I assume I will have to create a string that contains the values of the checkboxes joined together with delimiters because it is not possible to POST and actual array? So how do I obtain the values of the checkboxes for each individual question using JavaScript?
View 1 Replies
View Related
Aug 17, 2010
I want to run an external function outside the post.
This is what I have currently.
On success of the post I want to run the setGrandTotal(); function which will do some calculating for me.
View 1 Replies
View Related
Oct 11, 2011
How can I post array of controls through &.post() in jQuery??I have some of checkboxs in my page and declare them like this
<input name="mycheckbox[]" "value="myvalue" type="checkbox">
I can get it works if I using <form> tag with an action="post" and a submit button to post to another php page by using this statement to get all controls in receiver's page _GET['mycheckbox'];I have tried
$.post('ajax/test.php", {checkbox: $
(
'input[name="mycheckbox"]'
)});
[code]....
View 1 Replies
View Related
Dec 6, 2011
I just started using jQuery, but i can't get it working. On the index.php page I want a search form, that post's to search.php. Following next, I want that the html of search.php (which will only be a table with the results), is show into the 'results' div in the index.php.
This is the code im using:
<script type="text/javascript">
/* attach a submit handler to the form */
$(document).ready(function(){
alert("Ok - 1");
[Code].....
The alert's are for debugging, but none of them show's up.
View 3 Replies
View Related
Dec 5, 2009
In my project i am using ajax and jquery. After going to a page via ajax without page reload i want to see the same page if the user refresh the browser. I used the cookie plugin inorder to solve. As it is not safe i am trying to do the same using session. I have dowloaded the jquery session plugin and initialized the session variable using the below satements.
var SESSION_URL = $.session("current_url",Url);
var SESSION_DATASTRING = $.session("dataString",dataString);
and i am getting the session value in the same jquery $(function) where it is initialised, through alert($.session("current_url");
But i am not getting this session value in an another jquery event like
window.load(function(){
});
How can i get the initialized session value in an another event.
View 3 Replies
View Related
Oct 14, 2010
I have a button that selects all the checkbox.
How do I select all checkbox when running the click event of each?
View 2 Replies
View Related
Mar 6, 2011
I have a function that builds an xml string from all selected options in a form like this
function SetServices() {
var services = '<SERVICE><SERVICECD>1KNTK</SERVICECD></SERVICE>';
$(":checked:not([name='ServiceType'], #Standard, #NoneForex, #RTT, #PRN, #BW, #Metrics, #STATUS :input, #EX_AGREEMENTS :input, #final_step :input)").each(function() {
[Code].....
View 4 Replies
View Related
Feb 22, 2011
I am trying to reference a session variable inside some JQuery code. Theseexamples below arewhat I am using currently just to try and see if I can get something to display and nothing shows up.[code]Just to make sure an alert works, I threw in a alert("hi"); which works fine. It is when I try to write out the session variable it fails.
View 8 Replies
View Related