简体   繁体   中英

PHP font-size from HTML Form

I have a little problem. I'd like to change the text size of a link by using variable from form. I have tried using this simple process but it doesn't do anything.

Form part

<label name="size">Text size:</label>
    <input type="text" name="size">



if(isset($_POST['size'])) {
  $size = $_POST["size"];
}

if(isset($url)) {
  if(isset($_POST["okno"])) {
    echo "<a href='$url' title='$titul' target=_blank style='color:'$barva' font-size:'$size'>$zobrazeni</a>";
  } else {
      echo "<a href= '$url' title='$titul' style='color:$barva' font-size:'$size'>$zobrazeni</a>";
    }      
  } 

Replace your code with the following

if(isset($url)) {
    if(isset($_POST["okno"])) {
        echo "<a href='$url' title='$titul' target='_blank' style='color:$barva;font-size:$size;'>$zobrazeni</a>";
    } else {
        echo "<a href= '$url' title='$titul' style='color:$barva;font-size:$size;'>$zobrazeni</a>";
    }      
}

Drop the single quotes ( ' ) around the style properties color and font-size . Those are causing a parsing error in your HTML. Also, you must have a semicolon ( ; ) between the two:

if(isset($_POST['size'])) {
    $size = $_POST["size"];
}

if(isset($url)) {
    if(isset($_POST["okno"])) {
        echo "<a href='$url' title='$titul' target=_blank style='color:$barva; font-size:$size>$zobrazeni</a>";
    } else {
        echo "<a href= '$url' title='$titul' style='color:$barva; font-size:$size>$zobrazeni</a>";
    }      
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM