Horje

Tips (Total 2)


# Tips-1) How to crearte HTML textarea auto expand height

When You will write anything on textarea. It will auto height expand.

CSS Code

CSS Style Code for Textarea
style.css
Example: CSS
<style>
textarea {
  resize: none;
  overflow: hidden;
  min-height: 50px;
  max-height: 100px;
}    
</style>

Javascript Code

Javascript Code for making expand textarea when Wirte
script.js
Example: JAVASCRIPT
<script>
function auto_grow(element) {
  element.style.height = "5px";
  element.style.height = (element.scrollHeight) + "px";
}    
</script>

Full Completed Code for HTML textarea auto expand height

index.html
Example: HTML
<script>
function auto_grow(element) {
  element.style.height = "5px";
  element.style.height = (element.scrollHeight) + "px";
}    
</script>
<style>
textarea {
  resize: none;
  overflow: hidden;
  min-height: 50px;
  max-height: 100px;
}    
</style>
<textarea oninput="auto_grow(this)">
</textarea>

Output should be:

Full Completed Code for HTML textarea auto expand height

# Tips-2) How to use multiple values in HTML Select Option Tag?

I achieved it by using the PHP explode function, like this:

Step-1: HTML Form in a file I named doublevalue.php

Follow the Example.
index.html
Example: HTML
    <form name="car_form" method="post" action="doublevalue_action.php">
            <select name="car" id="car">
                    <option value="">Select Car</option>
                    <option value="BMW|Red">Red BMW</option>
                    <option value="Mercedes|Black">Black Mercedes</option>
            </select>
            <input type="submit" name="submit" id="submit" value="submit">
    </form>

Step-2: PHP action in a file I named index.php

Follow the Example.
doublevalue.php
Example: PHP
    <?php
            $result = $_POST['car'];
            $result_explode = explode('|', $result);
            echo "Model: ". $result_explode[0]."<br />";
            echo "Colour: ". $result_explode[1]."<br />";
    ?>


Share on: