Sunday, April 16, 2017

Clear data in modal when click close in Laravel

I have a modal(bootstrap) for create new product. So, when i clicked button close and after that click create new product,the old data still not clear. My code:

<div class="modal fade" id="product" role="dialog" aria-hidden="true" data-target="#myModal"   data-backdrop="static"  data-keyboard="false" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Create new product</h4>
            </div>
            <div class="modal-body">
                <form role="form" action="" method="post" id="frmProduct">
                    
                    <input type="hidden" name="_token" value="">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="">Product Name</label>
                                <input type="text" class="form-control" id="" name="product_name">
                            </div>
                            <div class="form-group">
                                <label for="">Product Type</label>
                                <input type="text" class="form-control" id="" name="product_type_id">
                            </div>
                            <div class="form-group">
                                <label for="">Price</label>
                                <input type="text" class="form-control" id="" name="price">
                            </div>
                            <div class="form-group">
                                <label for="">Status</label>
                                <select class="form-control input-sm m-bot15" id="" name="status">
                                    <option value="0">Inactive</option>
                                    <option value="1">Active</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="img">Image</label>

                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <span class="btn btn-default btn-file">
                                            Choose <input type="file" id="imgInp">
                                        </span>
                                    </span>
                                    <input type="text" class="form-control" name="product_image" readonly>
                                </div>
                                <img id='img-upload' class="image_responsive" />
                            </div>
                        </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="">Description</label>
                            <textarea class="form-control" id="" name="description"></textarea>
                        </div>
                        <div class="form-group">
                            <label for="">Note</label>
                            <textarea class="form-control" id="" name="addition_information"></textarea>
                        </div>

                    </div>
                </div>
            </div>
            <div class="modal-footer">
                    <input type="submit" value="Save" class="btn btn-success">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </form>
    </div>

</div>
</div>

So how can i clear data when clicked close modal?



via John

Advertisement