Labels

Android (1) Apache (1) bash (2) boost (2) C (37) C++ (5) cheatsheet (2) CLion (6) css (3) Debian (34) DL (17) dns (1) Docker (3) Dreamweaver (2) Eclipse (3) fail2ban (5) git (6) GitHub (5) Hacking (4) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (33) javascript (3) Linux (182) Mac (21) Machine Learning (1) mySQL (53) Netbeans (6) Networking (1) Nexus (1) OpenVMS (6) Oracle (4) Pandas (3) php (17) Postgresql (8) Python (9) raid (1) RedHat (15) Samba (2) Slackware (52) SQL (14) ssh (1) svn (1) tar (1) ThinkPad (1) Virtualbox (4) Visual Basic (2) Visual Studio (1) Windows (7) wire (1)
Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Wednesday, 30 August 2023

HTML mouse over hover text

The following examples should work;

<td title="Look at me" >Hover Over me</td>
<p title="Look at me" >Hover Over me</p> 
// We can also use php in there, like the below; 
<td title="<?= get_message_text($row['MESSAGE_NO']) ?>"><?= $row['MESSAGE_NO'] ?></td>
 

Friday, 1 April 2022

How to echo a double space with PHP

When echoing text with PHP, if the string contains more than one space, the extra spaces are lost when rendered in the browser.

the following is a workaround;

str_replace(' ', '&nbsp', $my_text);

This is especially important if we want to display values returned from a database query and the value has a double space for example and of course if that double space is important.


Tuesday, 21 September 2021

Detect screen size in php

Detecting the screen size in php, is not something that can be done with php alone but the following is what I use to kind of get around it.

Saturday, 17 April 2021

HTML date picker

<label for="start">Start date:</label>
<input type="date" id="start" name="trip-start"
       value="2018-07-22"
       min="2018-01-01" max="2018-12-31">

Thursday, 30 April 2020

Change text in an HTML document and passing php variable to javascript.

To change text in an html document or web page, we can use javascript.

If we were using php to echo the html then unfortunately, once the echo is done, the html is created so to speak and it's no longer possible to change or update it.

But, we can use javascript, as per the example below, where the 1st line could be high up on the page and would display old text and once the script below runs, this old text would be changed to new text.

This can of course be done by embedding php echo statements to include variables, which is also a way of passing a variable from php to javascript.



<p align="left" id="id1">old text</p>


<script>
document.getElementById("id1").innerHTML = "new text";
</script>

OR

<script>
document.getElementById("dt").innerHTML = "<?php echo $someVar ?>";
</script>

Tuesday, 28 April 2020

basic web page redirect or reload

The following is a basic web page redirect;

<html>
  <head>
    <meta HTTP-EQUIV="refresh" CONTENT="3; URL=index.html">
  </head>
</html>

 
The following is a basic javascript equivalent;
 
<script>
setTimeout(function () 
{
   // 5 seconds
   window.location.href= 'index.html';
}, 5000);
</script>
 
 
 
To reload a page without getting an alert, we can do the following;
 
<script>
    function reload_page()
    {
        window.location = window.location.href;
    }
</script>
 
then call it by;
 
<script type="text/javascript">
     reload_page();
</script>';
 
or from php;
 
echo '<script type="text/javascript">'.'reload_page();'.'</script>';


To call the function after some time, for example, to refresh the page in 5 seconds, we can do the following to call the reload_page function detailed above;


<script>
setTimeout(reload_page,5000);
</script>