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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:31:40+00:00 2026-05-28T17:31:40+00:00

I need to have a toggle button where … JQuery and Php needed here?

  • 0

I need to have a toggle button where …

JQuery and Php needed here?

If I click it one…the input hidden will be:

// Display this one if $myPhpVar isset
<input type="hidden" name="myHidden" id="myHidden" value="<?php echo $myPhpVar ?>" /> 

and if I click again:

// Display this one if $myPhpVar is not empty
<input type="hidden" name="myHidden" id="myHidden" value="" /> 

Hope I’ve explaining properly.

UPDATE: What I want to do is that If $myVar is not empty when I click button X then it will set the value to blank.

  • 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-28T17:31:41+00:00Added an answer on May 28, 2026 at 5:31 pm

    Here you go :

    var phpvar = "<? php echo $myPhpVar ?>";
    
    $('#myButton').toggle(function() {
    $('myHidden').val(phpvar);
    } ,function() {
    $('myHidden').val('');
    });
    

    and example fiddle : http://jsfiddle.net/8dwNf/1/

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

Sidebar

Related Questions

I have some JQuery Code as follows: $(#sh-zone-button-cart-menu).live(click, function(event) { event.preventDefault(); $(#sh-zone-cart-menu).toggle(0, function(){ if($(this).is(:visible)){
I have some HTML that I need to toggle between two structures - one
Ok so i have this Jquery that will toggle some radio buttons on the
I need to toggle existing android contacts to favourite. I have a toggle button
I'm using Javascript/Jquery to have a button toggle which div is displayed in the
I need a help in working with GPS Logger. I have a toggle button.
I need to have the user make a selection using radio button and the
I have a form which is validated through jquery, but I need the blur
Ok thanks to the guys on here we have sorted functions for checkbox click,
I have a case where I need to toggle the visibility of an element

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.