Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:15:41+00:00 2026-06-09T05:15:41+00:00

I am using $_SESSION to pass back a value in the event of page

  • 0

I am using $_SESSION to pass back a value in the event of page redirect.

As jquery cannot access $_SESSION I decided to use PHP to output the value to a hidden div and remove that div once the value had been picked up. I expect that there is a neater way to do this but I don’t know how else to expose the $_SESSION variable to jquery.

<?php       
    $pass_Back = $session->get_Pass_Back();
    $session->clear_Pass_Back();
?>

<?php
    if (count($pass_Back) != 0){
        echo "<input class=\"field_Input_Left\" id=\"schedule_Description\" type=\"text\" name=\"schedule_Description\" value=\"" . array_shift($pass_Back) . "\"/><br />";
        echo "<div id=\"pass_Back\" style=\"visibilty: hidden;\" ></div>";
    } else {    
        echo "<input class=\"field_Input_Left\" id=\"schedule_Description\" type=\"text\" name=\"schedule_Description\"/><br />";
    }
?>

Once this was done I needed a method to let jquery know if and when this new element was added to the DOM. Hence I used the plugin livequery to match when the element added. This it does which is great.

But when I try to access the value in the div it states that it is undefined.

$("#pass_Back").livequery(function(){
    if ($("#class_Name").val() != 0){
        var class_Name = $("#class_Name").val();
        get_Schedule_Data(class_Name);
    } else {
        var class_Name = "ALL";
        get_Schedule_Data(class_Name);
    }   


    $value = $(this).attr("value");
    auto_Fill_Schedule($("#pass_Back").attr("value"));

    // destroy pass back

    $("#pass_Back").remove();
});

When reviewed in firebug I note that at the point that livequery finds the added element no html is displayed. The DOM is ready otherwise the livequery couldn’t have functioned but is this why no value is found?

Any guideance gratefully received.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:15:42+00:00Added an answer on June 9, 2026 at 5:15 am

    Don’t use this:

    $value = $(this).attr("value");
    

    Do the following to get a value (for inputs in most of cases):

    (assuming $(this) is your input)

    $value = $(this).val();
    

    For div cases, there is no value, but you can get the html or text from inside as the value:

    (assuming $(this) is your div)

    $value = $(this).html();
    //or:
    $value = $(this).text();
    

    Just to know…

    You can mix PHP with jQuery but take a look at my answer from this post for better understanding:

    Is echoing Javascript code condtionally based on server-side logic considered harmful?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a Session variable to pass a datatable from 1 page to
I'm using .net httpwebrequest &/or webclient class How can i Progamatically pass a url
I am passing variables to another page with this urlencoded string http://localhost:8888/proseat/index.php/configure/ve/Honda/Civic+%28sedan%29/2007 and when
My website allows visitors to search for homes (using PHP and MySql). After the
I am trying to get the value from the radio boxes/button with php. The
When the user gets to my page (similar to the Google Plus API PHP
I am using session_start(); at the top of my login page. After a user
I'm trying to pass some values from one .aspx page to an handler (.ashx).
I have a javascript variable that I want to pass back to the server
I'm using CakePhp 2.2 and I have this simple controller, named ProvidersController : <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.