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 7625007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:08:05+00:00 2026-05-31T05:08:05+00:00

I have a hidden div in a ctp file. <div id=UserId style=visibility:hidden;> <?php $UserId

  • 0

I have a hidden div in a ctp file.

<div id="UserId" style="visibility:hidden;">
    <?php 
        $UserId = $app['Auth']['User']['id'];
        echo $UserId;
    ?>
</div>

I need to get this $userId value in a .js file.

var user_id = $("#userId").val();
alert(user_id);

But I got empty value. Please help…

I tried with var current_user_id = $("#userId").html();
but it shows the value in the center of the alert box and if i use that value in if condition, it does not return true for the condition.

For eg: say user_id value is 5.
A = 5

if (A == user_id){
  alert(1);
} else {
  alert(2);
}

It always returns 2.

  • 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-05-31T05:08:06+00:00Added an answer on May 31, 2026 at 5:08 am

    Either get the value using .innerHTML or use an <input /> tag to store your value for example:

    $UserId = $app['Auth']['User']['id'];
    echo "<input type = 'text' 
                 id = 'UserId' 
                 style = 'display: none;' 
                 value = '" . $UserId . "' />";
    

    you see <div> tags don’t have values

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

Sidebar

Related Questions

I have a hidden div: <div id=termSheetPrinted style=visibility:hidden;> </div> that I am populating through
Let's say we have a box with some short paragraphs: <div style=overflow:hidden> <p>Some text</p>
I have a hidden div that opens up with a user clicks on the
I have a img tag embedded inside a hidden div . When the user
Greetings, Assume that I have such hidden div: <div id=option-dialog style=display:none;> <a href=# value=1>First</a>
I have a drop-down and need to show hidden div that corresponds to the
I have a hidden div which is faded in using jquery when the user
I have a (visibility:hidden) div with a Drop Down menu and a jQuery datepicker
I am trying get a div that I have hidden to show in the
I have a hidden div which I reveal with the jquery fadein() method: $(#panel).fadeIn(slow);

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.