-3

My index page contains popup box. I want to replace index page title by popup box title if popup box clicked.

For example

<title><?php echo $title?></title>

I want to display as following:

<?php
    if(condition){      (->*such as #model2 is clicked*)
        $title="Model2 Section";
    }
    else{
        $title="Home"
    }
?>

I have used popup box as following:-> (link for popup box)

<article>
<a href="#modal2" class="dsnbutton ybank" id="pop_button">Model 2</a>
</article>

popup box

<div class="remodal" data-remodal-id="modal2" role="dialog" aria-labelledby="modal2Title" aria-describedby="modal2Desc">

How to change title ? Any Idea.

Dipak
  • 931
  • 14
  • 33
  • 2
    You are expected to **try to write the code yourself**. After [**doing more research**](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Jay Blanchard Sep 20 '17 at 15:06
  • Just to be clear - you're asking how to echo a PHP variable in to some HTML? – Rory McCrossan Sep 20 '17 at 15:06
  • Yes @RoryMcCrossan I want to echo php variable. I want to change page title dynamically. Let me clarify clearly, the title of default page is home, and if popup window is displayed (through #href tag), I want to change and echo another title. – Dipak Sep 20 '17 at 15:21
  • Possible duplicate of [Changing the page title with Jquery](https://stackoverflow.com/questions/7173596/changing-the-page-title-with-jquery) – Calimero Sep 20 '17 at 15:25

1 Answers1

1

You can do this in JavaScript with document.title = "new title"

Nick De Jaeger
  • 1,247
  • 10
  • 13