0

I can't figure out how to get the "Bought!" alert into the HTML template. Can someone help me out?

On the left is the "Brought!" alert i want.
On the right is an exhibition of my noob-ness. enter image description here

Here is my html code, I attempted to use if conditions in Jinja to do it, but don't seem to be able to get it to function properly. 1) Is "IF condition" the best way to do this? If not what is a better way? 2) How can i actually use the "IF conditions" that Jinja allows to make this happen (e.g. what is wrong with Jinja syntax/code(?))

{% extends "layout.html" %}

{% block title %}
    Index
{% endblock %}

{% block main %}

    <!--<form action="{{ url_for('buy') }}" method="post">..?-->
{% if request.method == "GET" %}
    <header>
        <div class="alert alert-info" role="alert">
            Bought!
        </div>
    </header>
{% endif %}

    <h2>RESULTS:</h2>

    <ul>
        <li><h2> {{ name }}</h2></li>
    </ul>

<table class="table table-striped">

        <thead>
            <th>Share Symbol</th>
            <th>Shares Name</th>
            <th>Number of Shares</th>
            <th>Current price</th>
            <th>Total value</th>
        </thead>

         {% for share in sharesOwned %}
            <tr>
                <td>{{ share.symbol }}</td>
                <td>{{ share.name }}</td>
                <td>{{ share.quanties }}</td>
                <td>{{ share.priceNow|round(2, 'floor') }}</td>
                <td>{{ share.totalValueNow|round(2, 'floor') }}</td>
            </tr>

        {% endfor %}

        <!--{% for i in priceNow%}-->
        <!--    <td>-->
        <!--        <tr>{{ priceNow }}</td>-->
        <!--    </td>-->
        <!--{% endfor %}-->

        <tr>
            <td colspan="4">CASH</td> 
            <td>{{ totalCash }}</td>


        </tr>

        <tfoot>
            <tr>
                <td colspan="4">
                    <td> 
                        <b>{{ countWithCash|round(2,'floor') }}</b>
                    </td>
                </td> 
            </tr>
        </tfoot>        


    </table>



{% endblock %}
    <!--<form action="{{ url_for('buy') }}" method="post">-->
    <!--    {% for stock in stocks%}-->
    <!--        <p>{{stock.name}}</p>-->
    <!--    {%endfor%}-->

        <!--<fieldset>-->
        <!--    <div class="form-group">-->
        <!--        <input autocomplete="off" autofocus class="form-control" name="symbol" placeholder="Symbol" type="text"/>-->
        <!--    </div>-->

        <!--    <div class="form-group">-->
        <!--        <input class="form-control" name="shares" placeholder="Shares" type="number"/>-->
        <!--    </div>-->


        <!--    <div class="form-group">-->
        <!--        <button class="btn btn-default" type="submit">Buy</button>-->
        <!--    </div>-->
        <!--</fieldset>-->
    <!--</form>-->

Thanks so much in advance! really appreciate the community!

1
  • Hey there, the colors ect are not the same though, it's blue instead of green, who will i be able to change the color? – nvs0000 Jun 11 '17 at 16:59
1

@dinocodersaurus's link :)

flash ("Bought") 
return redirect(url_for("index"))
1
  • Hey there, the colors ect are not the same though, it's blue instead of green, who will i be able to change the color? – nvs0000 Jun 11 '17 at 16:59

Not the answer you're looking for? Browse other questions tagged .