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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:06:57+00:00 2026-06-14T07:06:57+00:00

Can anyone please help me on this: I am trying to add a classname/

  • 0

Can anyone please help me on this:

I am trying to add a classname/ change the css of div using jquery; after I click submit on the form. Means, after clicking submit and when the page reloads this classname/ changes should stick to the target element. I am using php to get the values of form submitted. (no ajax, but if necessary I can modify my code). I tried to do this by jquery but when the page reloads the changes are gone !

Thanks.

update: Here is the sample code(so.php itself) I am working on. after form is submitted and page is reloaded; say I want to add a class to input that is clicked and manage the style in CSS:

<html>
<head>
</head>
<body>
<form id="myForm" action="so.php" method="get">
    <input name="Load" type="submit" value="Google" />
    <input name="Load" type="submit" value="MSN" />
    <input name="Load" type="submit" value="Yahoo" />
</form>     
<div id="container">
    <?php
        if (isset($_GET['Load'])) {
            $value = $_GET['Load'];
            echo "<iframe width=\"560\" height=\"349\" src=\"http://www.{$value}.com\"></iframe>";
        }
    ?>
</div>
</body>
</html>

update2: I tried the logic provided by @NoPyGod and it worked. But here is the thing. I am trying to add a class to the button that is selected as well as update the text in the div with id “hello” with the value of input that is clicked or in active state once the form is submitted and page is reloaded. This is the one I ended up but once form is submitted
all the inputs are having the same class name as well the text in div is also not updated.

<html>
<head>
<?php if (isset($_GET['Load'])): ?>
<script>
    $(document).ready(function() {
        $('#hello').text('Hello');
    });
</script>
<?php endif; ?>
</head>
<body>
<form id="myForm" action="so.php" method="get">
    <input class="<?php if (isset($_GET['Load'])) { echo "some_class"; } if (isset($_GET['Load1'])) { echo "some_class1"; }?>" name="Load" type="submit" value="Google" />
    <input class="<?php if (isset($_GET['Load'])) { echo "some_class"; } if (isset($_GET['Load1'])) { echo "some_class1"; }?>" name="Load1" type="submit" value="Rediff" />
    <input class="<?php if (isset($_GET['Load'])) { echo "some_class"; } if (isset($_GET['Load1'])) { echo "some_class1"; }?>" name="Load" type="submit" value="Yahoo" />
  <input class="<?php if (isset($_GET['Load'])) { echo "some_class"; } if (isset($_GET['Load1'])) { echo "some_class1"; }?>" name="Load1" type="submit" value="Sify" />
</form>

<div id="container" >
    <?php
        if (isset($_GET['Load'])) {
            $value = $_GET['Load'];
            echo "<iframe width=\"560\" height=\"349\" src=\"http://www.{$value}.com\"></iframe>";
        }
        if (isset($_GET['Load1'])) {
            $value = $_GET['Load1'];
            echo "<iframe width=\"560\" height=\"349\" src=\"http://www.{$value}.com\"></iframe>";
        }
    ?>
</div>

<div id="hello"></div>

</body>
</html>
  • 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-14T07:06:58+00:00Added an answer on June 14, 2026 at 7:06 am

    When the page is submitted, set a variable like so

    $was_submitted = true;
    

    Then in your HTML do something like this

    <div id="myid" class="<?php if ($was_submitted) { echo "some_class"; } ?>">
    

    Or if you absolutely insist on using jQuery to change it, include this in your html —

    <?php if ($was_submitted): ?>
    
    <script>
        $(document).ready(function() {
            $("#myid").addClass("some_class");
        });
    </script>
    
    <?php endif; ?>
    

    Updated:

    <html>
    <head>
    </head>
    <body>
    <form id="myForm" action="so.php" method="get">
        <input name="Load" type="submit" value="Google" />
        <input name="Load" type="submit" value="MSN" />
        <input name="Load" type="submit" value="Yahoo" />
    </form>
    
        <!-- I changed this line below -->
    
        <div id="container" class=<?php if (isset($_GET['Load'])) { echo "some_class"; } ?>>
        <?php
            if (isset($_GET['Load'])) {
                $value = $_GET['Load'];
                echo "<iframe width=\"560\" height=\"349\" src=\"http://www.{$value}.com\"></iframe>";
            }
        ?>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone please help me with this. I am new to css styling. I
Can anyone please help me with this...I'm not very good with regular expressions and
Can anyone help me spot the problem on this PLEASE? I'm eternally grateful for
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Can anyone please help. I am trying to convert excel data into xml file
Can any one please help me solve this. I am resizing some flash object/embed
Can anyone please help me to know how to open an excel sheet in
Can anyone please help me to work out how to achieve the following? I
Can anyone please help me to understand how should i access json data in
Can anyone please help. I'm following a tutorial found here as I have a

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.