在同一页面上使用javaScript无法获得价值

时间:2017-05-22 16:01:39

标签: javascript php debugging laravel-5.2

get_quotes.blade.php

<form enctype="multipart/form-data">
    <div class="form-group">
        Please fill details to find more packages!
    </div>
    <div class="form-group">
        <div class="row">
            <div class="col-sm-4">
                <select class="form-control" name="hos_1" id="hos_1">
                    <option value="" selected>--Hospital Preferance 1--</option>
                    @if(isset($address))
                        @foreach($address as $key => $hos)
                            <option value="{{$hos->hos_name}}">{{$hos->hos_name}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <div class="col-sm-4">
                <select class="form-control" name="hos_2" id="hos_2">
                    <option value="" selected>--Hospital Preferance 2--</option>
                    @if(isset($address))
                        @foreach($address as $key => $hos)
                            <option value="{{$hos->hos_name}}">{{$hos->hos_name}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <div class="col-sm-4">
                <select class="form-control" name="hos_3" id="hos_3">
                    <option value="" selected>--Hospital Preferance 2--</option>
                    @if(isset($address))
                        @foreach($address as $key => $hos)
                            <option value="{{$hos->hos_name}}">{{$hos->hos_name}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <hr>
        </div>
    </div>
    <div class="form-group">
        <div class="row">
            <div class="col-sm-4">
                <select class="form-control" name="city_1" id="city_1">
                    <option value="" selected>--City Preferance 1--</option>
                    @if(isset($address))
                        @foreach($address as $key => $add)
                            <option value="{{$add->address}}">{{$add->address}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <div class="col-sm-4">
                <select class="form-control" name="city_2" id="city_2">
                    <option value="" selected>--City Preferance 2--</option>
                    @if(isset($address))
                        @foreach($address as $key => $add)
                            <option value="{{$add->address}}">{{$add->address}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <div class="col-sm-4">
                <select class="form-control" name="city_3" id="city_3">
                    <option value="" selected>--City Preferance 2--</option>
                    @if(isset($address))
                        @foreach($address as $key => $add)
                            <option value="{{$add->address}}">{{$add->address}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
            <hr>
        </div>
    </div>
    <div class="form-group">
        <div class="row">
            <div class="col-sm-8"><label>Any preferance for doctor (If you have in mind!)</label></div>
            <div class="col-sm-4"><label>Max Budget!</label></div>
        </div>
    </div>
    <div class="form-group">
        <div class="row">
            <div class="col-sm-4">
                <input type="text" class="form-control" name="doc_1" id="doc_1" placeholder="Fill Doctor Name" value="">
            </div>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="doc_2" id="doc_2" placeholder="Fill Doctor Name" value="">
            </div>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="budget" id="budget" placeholder="Fill Budget Price"
                       value="">
            </div>
        </div>
    </div>
    <div id="post-16"
         class="post-16 post type-post status-publish format-standard has-post-thumbnail hentry category-events category-places-to-visit tag-excepteur-sint">
        <div class="post_info clearfix">
            <div class="form-group">
                <div class="row">
                    <div class="col-sm-12"><label> Do you want extend you services during recovery period?</label></div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_1" id="check_1" value="1">
                    <span style="font-size:10px">Accomodation</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_2" id="check_2" value="1">
                    <span style="font-size:10px">Texi</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_3" id="check_3" value="1">
                    <span style="font-size:10px">Translater</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_4" id="check_4" value="1">
                    <span style="font-size:10px">Paramedic services</span>
                </div>
            </div>
        </div>
    </div>
    <div id="post-16"
         class="post-16 post type-post status-publish format-standard has-post-thumbnail hentry category-events category-places-to-visit tag-excepteur-sint">
        <div class="post_info clearfix">
            <div class="form-group">
                <div class="row">
                    <div class="col-sm-12"><label>Any other services, Do you want to include in your trip?</label></div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_5" id="check_5" value="1">
                    <span style="font-size:10px">Tour package</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_6" id="check_6" value="1">
                    <span style="font-size:10px">Wellness Package</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_7" id="check_7" value="1">
                    <span style="font-size:10px">Tample Tourism</span>
                </div>
                <div class="col-sm-3">
                    <input type="checkbox" class="form-group" name="check_8" id="check_8" value="1">
                    <span style="font-size:10px">Return Flight Ticket</span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="row">
                <div class="col-sm-12"><label>More Details!</label></div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <textarea class="form-control" name="details" rows="5" id="details" value=""></textarea>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="row">
                <div class="col-sm-12"><label>Upload file of medical report summary!</label></div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <input name="report_file" id="report_file" type="file">
                </div>
            </div>
        </div>
        <div align="center">
            <a href="#" class="btn_1 green" onclick="get_value()" data-toggle="modal"
               data-target="#myReview17">Submit</a>
        </div>
    </div>
</form>
</div></div></div>
</div>

<div class="modal fade" id="myReview17" tabindex="-1" role="dialog" aria-labelledby="myReviewLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        {!!Form::open(['action' => 'GetEstimationController@_login', 'method' => 'post','role' => 'search', 'id'=>'search-tour-form'])!!}
                        <h2>Please Fill Up
                            <small>Get Multiple quotes from expert.</small>
                        </h2>
                        <hr class="colorgraph">
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">
                                    <input type="text" name="full_name" id="full_name" class="form-control input-lg"
                                           placeholder="Full Name" tabindex="1">
                                </div>
                            </div>

                            <input type="hidden" name="hos_1" id="hos_1">
                            <input type="hidden" name="hos_2" id="hos_2">
                            <input type="hidden" name="hos_3" id="hos_3">
                            <input type="hidden" name="city_1" id="city_1">
                            <input type="hidden" name="city_2" id="city_2">
                            <input type="hidden" name="city_3" id="city_3">
                            <input type="hidden" name="doc_1" id="doc_1">
                            <input type="hidden" name="doc_2" id="doc_2">
                            <input type="hidden" name="budget" id="budget">
                            <input type="hidden" name="check_1" id="check_1">
                            <input type="hidden" name="check_2" id="check_2">
                            <input type="hidden" name="check_3" id="check_3">
                            <input type="hidden" name="check_4" id="check_4">
                            <input type="hidden" name="check_5" id="check_5">
                            <input type="hidden" name="check_6" id="check_6">
                            <input type="hidden" name="check_7" id="check_7">
                            <input type="hidden" name="check_8" id="check_8">
                            <input type="hidden" name="details" id="details">

                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">
                                    <input type="text" name="mobile_no" id="mobile_no" class="form-control input-lg"
                                           placeholder="Mobile No" tabindex="2">
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">
                                    <input type="email" name="email_id" id="email_id" class="form-control input-lg"
                                           placeholder="Email Address" tabindex="5">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">
                                    <input type="text" name="pat_age" id="pat_age" class="form-control input-lg"
                                           placeholder="Patient Age" tabindex="5">
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">

                                    <select tabindex="1" class="form-control input-lg" name="gender" id="gender">
                                        <option value="">Select Gender</option>
                                        <option value="Male">Male</option>
                                        <option value="Female">Female</option>

                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-6 col-md-4">
                                <div class="form-group">

                                    <select tabindex="1" class="form-control input-lg" name="country" id="country">
                                        <option value="-1">Select Country</option>
                                        <option value="+93">Afghanistan - AF</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-4 col-sm-3 col-md-3">
                        <span class="button-checkbox">
                            <button type="button" class="btn" data-color="info" tabindex="7">I Agree</button>
                            <input type="checkbox" name="t_and_c" id="t_and_c" class="hidden" value="1">
                        </span>
                            </div>
                            <div class="col-xs-8 col-sm-9 col-md-9">
                                <input type="checkbox"
                                       onchange="document.getElementById('sendNewSms18').disabled = !this.checked;"/> By
                                clicking <strong class="label label-primary">Submit</strong>, you agree to the <a
                                        href="#" data-toggle="modal" data-target="#t_and_c_m">Terms and Conditions</a>
                                set out by this site, including our Cookie Use.
                            </div>
                        </div>

                        <hr class="colorgraph">
                        <div class="row">
                            <div class="col-xs-12 col-md-6"><input type="submit" id="sendNewSms18" value="Submit"
                                                                   class="btn btn-primary btn-block btn-lg" tabindex="7"
                                                                   disabled="disabled"></div>
                            <div class="col-xs-12 col-md-6"><a href="#" class="btn btn-success btn-block btn-lg"
                                                               data-dismiss="modal">Close</a></div>
                        </div>
{!!Form::close()!!}

用于在同一页面上获取值的JavaScript。

<script>
var hos_1; var hos_2; var hos_3;
var city_1; var city_2; var city_3; var doc_1; var doc_2;
var budget; var check_1; var check_2;
var check_3; var check_4; var check_5; var check_6; 
var check_7; var check_8; var details;
function get_value() { 
    var hos_1 = document.getElementById("hos_1");
    var hos_1 = hos_1.options[no.selectedIndex].text;
    var hos_2 = document.getElementById("hos_2");
    var hos_2 = hos_2.options[no.selectedIndex].text;
    var hos_3 = document.getElementById("hos_3");
    var hos_3 = hos_3.options[no.selectedIndex].text;
    var city_1 = document.getElementById("city_1");
    var city_1 = city_1.options[no.selectedIndex].text;
    var city_2 = document.getElementById("city_2");
    var city_2 = city_2.options[no.selectedIndex].text;
    var city_3 = document.getElementById("city_3");
    var city_3 = city_3.options[no.selectedIndex].text;
    var doc_1 = document.getElementById("doc_1").value;
    var doc_2 = document.getElementById("doc_2").value;
    var budget = document.getElementById("budget").value;
    if (document.getElementById('check_1').checked) {
        check_1 = document.getElementById('check_1').value;
    }
    if (document.getElementById('check_2').checked) {
        check_2 = document.getElementById('check_2').value;
    }
    if (document.getElementById('check_3').checked) {
        check_3 = document.getElementById('check_3').value;
    }if (document.getElementById('check_4').checked) {
        check_4 = document.getElementById('check_4').value;
    }
    if (document.getElementById('check_5').checked) {
        check_5 = document.getElementById('check_5').value;
    }
    if (document.getElementById('check_6').checked) {
        check_6 = document.getElementById('check_6').value;
    }
    if (document.getElementById('check_7').checked) {
        check_7 = document.getElementById('check_7').value;
    }
    if (document.getElementById('check_8').checked) {
        check_8 = document.getElementById('check_8').value;
    }
    var details = document.getElementById("details").value;
    set_value();
}

function set_value() {
    document.getElementById("hos_1").value = hos_1;
    document.getElementById("hos_2").value = hos_2;
    document.getElementById("hos_3").value = hos_3;
    document.getElementById("city_1").value = city_1;
    document.getElementById("city_2").value = city_2;
    document.getElementById("city_3").value = city_3;
    document.getElementById("doc_1").value = doc_1;
    document.getElementById("doc_2").value = doc_2;
    document.getElementById("budget").value = budget;
    document.getElementById("chcek_1").value = chcek_1;
    document.getElementById("chcek_2").value = chcek_2;
    document.getElementById("chcek_3").value = chcek_3;
    document.getElementById("chcek_4").value = chcek_4;
    document.getElementById("chcek_5").value = chcek_5;
    document.getElementById("chcek_6").value = chcek_6;
    document.getElementById("chcek_7").value = chcek_7;
    document.getElementById("chcek_8").value = chcek_8;
    document.getElementById("details").value = details;
}
</script>

但它没有用。工作一次,但在那之后它的相同代码不起作用。我尝试使用dd(hos_1)进行调试,但它在视图和控制器上都显示空值。

0 个答案:

没有答案