问:
Unable to get value of form with javascript
I am trying to get the value of a form from my javascript, but the value continues to return undefined as if the input does not exist.

Here is the html

```<code>%@ Language="VBScript" CodePage=65001 %>

<%
plan = Request("plan")
If plan = "" Then plan = "1"
modelid = Request("modelid")
If modelid = "" Then modelid = "0"

'plan = Request.Form("plan")
'If plan = "" Then plan = "1"
'modelid = Request.Form("modelid")
'If modelid = "" Then modelid = "0"
'Response.Write("plan= " & plan)
'Response.Write("modelid= " & modelid)
%>

<html>
    <head>
        ...

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.csv.js" charset="UTF-8"></script>

<script type="text/javascript">
    console.log(document.form1.plan.value);
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-16620217-8']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

</script>

...

</head>
     <body onLoad="...">
 ...
         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">
    <div id="container">
    <section id="model-select">
        <div class="content">

            <dl>
                <dt>車両・モデル</dt>
                <dd>
                    <div class="dropdown">
                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>ファイナンスプログラム</dt>
                <dd>
                    <div class="dropdown">
                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>
                    </div>
                </dd>
            </dl>
        <div class="question">
            <p><a href="http://www.citroen.jp/finance/auto_loan/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・オートローンに関して詳しくはこちら</a></p>
            <p><a href="http://www.citroen.jp/finance/passport/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・パスポートに関して詳しくはこちら</a></p>
        </div>
        </div>
    </section>
    <section id="config">
        <div class="content">
            <dl class="header-text">
                <dt>設定項目</dt>
                <dd>設定金額</dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>車両本体価格<br>（消費税抜き車両本体価格）</dt>
                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">
                <dd><p><span id="text_price_with_tax2">4,340,000円</span><br>(<span id="text_price2" class="f10px">1,983,333</span><span class="f10px">円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>ご購入サポート</dt>
                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">
                <dd><p class="blue"><span id="supported_price" class="btxt maintxt">-100,000</span><span class="f10px"> 円</span><br /><br /></span></p></dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>ご購入サポート適用後　メーカー希望小売価格<br class="sp-dn">
                    （消費税抜き車両本体価格）</dt>
                <dd><p id="purchase-support-div"><span id="supported_price_with_tax" class="f12pxb">2,550,000</span><span class="f10px"> 円</span><br /><span class="f08px"></span>(<span style="font-size:12px !important" id="supported_price_without_tax" class="f08px">2,361,112</span><span class="f08px"> 円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>金利（実質年率）</dt>
                <input type="hidden" name="rate" value="2.39">
                <dd><p><span name="rate" id="rate">2.39%</span></p></dd>
            </dl>
            <dl class="passport downpaymentform">
                <dt>シトロエン・パスポート</dt>
                <dd>
                    <div class="dropdown2">
                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>
                    </div>
                </dd>
            </dl>
            <dl class="downpaymentform">
                <dt>頭金</dt>

                <dd><div class="input"><input type="text" name="downpayment" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>諸費用・オプション代など</dt>
                <dd><div class="input"><input type="text" name="optionprice" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="lastpaymentform">
                <dt>ボーナス加算額</dt>
                <dd><div class="input"><input type="text" name="bonus" size="10" maxlength="6" class="blue"><p>円</p></div></dd>
            </dl>
        </div>

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">
    ...

</form>
    </section>
</code>```

I have this code console.log(document.form1.plan.value); that I am using to check the value of the input and my list of inputs is at the bottom of the html.

I am banging my head against a wall trying to trace this issue down so any answer is greatly appreciated

答:
Move your scripts that depend on parts of the page being ready to the bottom.

Right before the closing  tag.

```<code>...

<html>
    <head>
        ...

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.csv.js" charset="UTF-8"></script>

<script>
//analytics code goes here
//anything that needs to access the document needs to be below
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16620217-8']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script>

<!-- ====================== Moved from here... ====================== -->

...

</head>
     <body onLoad="...">
 ...
         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">
    <div id="container">
    <section id="model-select">
        <div class="content">

            <dl>
                <dt>車両・モデル</dt>
                <dd>
                    <div class="dropdown">
                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>ファイナンスプログラム</dt>
                <dd>
                    <div class="dropdown">
                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>
                    </div>
                </dd>
            </dl>
        <div class="question">
            <p><a href="http://www.citroen.jp/finance/auto_loan/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・オートローンに関して詳しくはこちら</a></p>
            <p><a href="http://www.citroen.jp/finance/passport/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・パスポートに関して詳しくはこちら</a></p>
        </div>
        </div>
    </section>
    <section id="config">
        <div class="content">
            <dl class="header-text">
                <dt>設定項目</dt>
                <dd>設定金額</dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>車両本体価格<br>（消費税抜き車両本体価格）</dt>
                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">
                <dd><p><span id="text_price_with_tax2">4,340,000円</span><br>(<span id="text_price2" class="f10px">1,983,333</span><span class="f10px">円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>ご購入サポート</dt>
                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">
                <dd><p class="blue"><span id="supported_price" class="btxt maintxt">-100,000</span><span class="f10px"> 円</span><br /><br /></span></p></dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>ご購入サポート適用後　メーカー希望小売価格<br class="sp-dn">
                    （消費税抜き車両本体価格）</dt>
                <dd><p id="purchase-support-div"><span id="supported_price_with_tax" class="f12pxb">2,550,000</span><span class="f10px"> 円</span><br /><span class="f08px"></span>(<span style="font-size:12px !important" id="supported_price_without_tax" class="f08px">2,361,112</span><span class="f08px"> 円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>金利（実質年率）</dt>
                <input type="hidden" name="rate" value="2.39">
                <dd><p><span name="rate" id="rate">2.39%</span></p></dd>
            </dl>
            <dl class="passport downpaymentform">
                <dt>シトロエン・パスポート</dt>
                <dd>
                    <div class="dropdown2">
                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>
                    </div>
                </dd>
            </dl>
            <dl class="downpaymentform">
                <dt>頭金</dt>

                <dd><div class="input"><input type="text" name="downpayment" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>諸費用・オプション代など</dt>
                <dd><div class="input"><input type="text" name="optionprice" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="lastpaymentform">
                <dt>ボーナス加算額</dt>
                <dd><div class="input"><input type="text" name="bonus" size="10" maxlength="6" class="blue"><p>円</p></div></dd>
            </dl>
        </div>

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">
    ...

</form>
    </section>

<!-- ====================== ...to here ====================== -->
<script type="text/javascript">
    console.log(document.form1.plan.value);
    /* ====================== INSERT JS HERE ====================== */

</script>
</body>
</html>
</code>```

Example:

         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">

車両・モデル

                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>

ファイナンスプログラム

                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>

シトロエン・オートローンに関して詳しくはこちら

シトロエン・パスポートに関して詳しくはこちら

設定項目

設定金額

車両本体価格
（消費税抜き車両本体価格）

                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">

4,340,000円
(1,983,333円)

ご購入サポート

                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">

-100,000 円

ご購入サポート適用後　メーカー希望小売価格

                    （消費税抜き車両本体価格）

2,550,000 円
(2,361,112 円)

金利（実質年率）

                <input type="hidden" name="rate" value="2.39">

2.39%

シトロエン・パスポート

                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>

頭金

<input type="text" name="downpayment" size="10" maxlength="7" class="blue">
円

諸費用・オプション代など

<input type="text" name="optionprice" size="10" maxlength="7" class="blue">
円

ボーナス加算額

<input type="text" name="bonus" size="10" maxlength="6" class="blue">
円

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">

</form>

```

See also:

Where to place Javascript in a HTML file?

$(document).ready equivalent without jQuery

Body:
I am trying to get the value of a form from my javascript, but the value continues to return undefined as if the input does not exist.

Here is the html

%@ Language="VBScript" CodePage=65001 %>

<%
plan = Request("plan")
If plan = "" Then plan = "1"
modelid = Request("modelid")
If modelid = "" Then modelid = "0"

'plan = Request.Form("plan")
'If plan = "" Then plan = "1"
'modelid = Request.Form("modelid")
'If modelid = "" Then modelid = "0"
'Response.Write("plan= " & plan)
'Response.Write("modelid= " & modelid)
%>

        ...

...

 ...
         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">

車両・モデル

                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>

ファイナンスプログラム

                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>

シトロエン・オートローンに関して詳しくはこちら

シトロエン・パスポートに関して詳しくはこちら

設定項目

設定金額

車両本体価格
（消費税抜き車両本体価格）

                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">

4,340,000円
(1,983,333円)

ご購入サポート

                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">

-100,000 円

ご購入サポート適用後　メーカー希望小売価格

                    （消費税抜き車両本体価格）

2,550,000 円
(2,361,112 円)

金利（実質年率）

                <input type="hidden" name="rate" value="2.39">

2.39%

シトロエン・パスポート

                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>

頭金

<input type="text" name="downpayment" size="10" maxlength="7" class="blue">
円

諸費用・オプション代など

<input type="text" name="optionprice" size="10" maxlength="7" class="blue">
円

ボーナス加算額

<input type="text" name="bonus" size="10" maxlength="6" class="blue">
円

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">
    ...

</form>

I have this code console.log(document.form1.plan.value); that I am using to check the value of the input and my list of inputs is at the bottom of the html.

I am banging my head against a wall trying to trace this issue down so any answer is greatly appreciated

Body:
Move your scripts that depend on parts of the page being ready to the bottom.

Right before the closing </body> tag.

...

<html>
    <head>
        ...

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.csv.js" charset="UTF-8"></script>

<script>
//analytics code goes here
//anything that needs to access the document needs to be below
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16620217-8']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script>

<!-- ====================== Moved from here... ====================== -->

...

</head>
     <body onLoad="...">
 ...
         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">
    <div id="container">
    <section id="model-select">
        <div class="content">

            <dl>
                <dt>車両・モデル</dt>
                <dd>
                    <div class="dropdown">
                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>ファイナンスプログラム</dt>
                <dd>
                    <div class="dropdown">
                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>
                    </div>
                </dd>
            </dl>
        <div class="question">
            <p><a href="http://www.citroen.jp/finance/auto_loan/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・オートローンに関して詳しくはこちら</a></p>
            <p><a href="http://www.citroen.jp/finance/passport/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・パスポートに関して詳しくはこちら</a></p>
        </div>
        </div>
    </section>
    <section id="config">
        <div class="content">
            <dl class="header-text">
                <dt>設定項目</dt>
                <dd>設定金額</dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>車両本体価格<br>（消費税抜き車両本体価格）</dt>
                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">
                <dd><p><span id="text_price_with_tax2">4,340,000円</span><br>(<span id="text_price2" class="f10px">1,983,333</span><span class="f10px">円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>ご購入サポート</dt>
                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">
                <dd><p class="blue"><span id="supported_price" class="btxt maintxt">-100,000</span><span class="f10px">&nbsp;円</span><br /><br /></span></p></dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>ご購入サポート適用後　メーカー希望小売価格<br class="sp-dn">
                    （消費税抜き車両本体価格）</dt>
                <dd><p id="purchase-support-div"><span id="supported_price_with_tax" class="f12pxb">2,550,000</span><span class="f10px">&nbsp;円</span><br /><span class="f08px"></span>(<span style="font-size:12px !important" id="supported_price_without_tax" class="f08px">2,361,112</span><span class="f08px">&nbsp;円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>金利（実質年率）</dt>
                <input type="hidden" name="rate" value="2.39">
                <dd><p><span name="rate" id="rate">2.39%</span></p></dd>
            </dl>
            <dl class="passport downpaymentform">
                <dt>シトロエン・パスポート</dt>
                <dd>
                    <div class="dropdown2">
                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>
                    </div>
                </dd>
            </dl>
            <dl class="downpaymentform">
                <dt>頭金</dt>

                <dd><div class="input"><input type="text" name="downpayment" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>諸費用・オプション代など</dt>
                <dd><div class="input"><input type="text" name="optionprice" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="lastpaymentform">
                <dt>ボーナス加算額</dt>
                <dd><div class="input"><input type="text" name="bonus" size="10" maxlength="6" class="blue"><p>円</p></div></dd>
            </dl>
        </div>

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">
    ...

</form>
    </section>

<!-- ====================== ...to here ====================== -->
<script type="text/javascript">
    console.log(document.form1.plan.value);
    /* ====================== INSERT JS HERE ====================== */

</script>
</body>
</html>

Example:

<html>
    <head>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.csv.js" charset="UTF-8"></script>

<script>
//analytics code goes here
//anything that needs to access the document needs to be below
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16620217-8']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script>

<!-- ====================== Moved from here ====================== -->

</head>
     <body onLoad="">

         <form NAME="form1" action="result_ct.asp" method="post" style="margin:0;">
    <div id="container">
    <section id="model-select">
        <div class="content">

            <dl>
                <dt>車両・モデル</dt>
                <dd>
                    <div class="dropdown">
                    <select name="model" id="model" onChange="calc_price_with_tax(); addComma2(); changeinstallments();">
                    </select>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>ファイナンスプログラム</dt>
                <dd>
                    <div class="dropdown">
                    <select name="planselect" id="planselect" onchange="changeplan(this)">
                    <option>シトロエン・オートローン</option>
                    <option>シトロエン・パスポート</option>
                    </select>
                    </div>
                </dd>
            </dl>
        <div class="question">
            <p><a href="http://www.citroen.jp/finance/auto_loan/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・オートローンに関して詳しくはこちら</a></p>
            <p><a href="http://www.citroen.jp/finance/passport/" target="_blank"><img src="images/question_03.png" alt="question-mark">シトロエン・パスポートに関して詳しくはこちら</a></p>
        </div>
        </div>
    </section>
    <section id="config">
        <div class="content">
            <dl class="header-text">
                <dt>設定項目</dt>
                <dd>設定金額</dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>車両本体価格<br>（消費税抜き車両本体価格）</dt>
                <input type="hidden" name="text_price_with_tax" id="text_price_with_tax" size="10" maxlength="7">
                <input type="hidden" name="text_price" id="text_price" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment37" size="10" maxlength="7">
                <input type="hidden" name="text_lastpayment61" size="10" maxlength="7">
                <dd><p><span id="text_price_with_tax2">4,340,000円</span><br>(<span id="text_price2" class="f10px">1,983,333</span><span class="f10px">円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>ご購入サポート</dt>
                <input type="hidden" name="support" id="support">
                <input type="hidden" name="supported_price_with_tax" id="supported_price_with_tax">
                <dd><p class="blue"><span id="supported_price" class="btxt maintxt">-100,000</span><span class="f10px">&nbsp;円</span><br /><br /></span></p></dd>
            </dl>
            <dl class="text-box-L downpaymentform">
                <dt>ご購入サポート適用後　メーカー希望小売価格<br class="sp-dn">
                    （消費税抜き車両本体価格）</dt>
                <dd><p id="purchase-support-div"><span id="supported_price_with_tax" class="f12pxb">2,550,000</span><span class="f10px">&nbsp;円</span><br /><span class="f08px"></span>(<span style="font-size:12px !important" id="supported_price_without_tax" class="f08px">2,361,112</span><span class="f08px">&nbsp;円)</span></p></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>金利（実質年率）</dt>
                <input type="hidden" name="rate" value="2.39">
                <dd><p><span name="rate" id="rate">2.39%</span></p></dd>
            </dl>
            <dl class="passport downpaymentform">
                <dt>シトロエン・パスポート</dt>
                <dd>
                    <div class="dropdown2">
                    <select name="installments" id="installments" onChange="changeinstallments()">
                        <option>3</option>
                            <option>5</option>
                                    </select>
                    </div>
                </dd>
            </dl>
            <dl class="downpaymentform">
                <dt>頭金</dt>

                <dd><div class="input"><input type="text" name="downpayment" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="downpaymentform">
                <dt>諸費用・オプション代など</dt>
                <dd><div class="input"><input type="text" name="optionprice" size="10" maxlength="7" class="blue"><p>円</p></div></dd>
            </dl>
            <dl class="lastpaymentform">
                <dt>ボーナス加算額</dt>
                <dd><div class="input"><input type="text" name="bonus" size="10" maxlength="6" class="blue"><p>円</p></div></dd>
            </dl>
        </div>

    <input onClick="Precheck()" type="submit" value="シミュレーションしてみる" id="simulation-button">

</form>
    </section>

<!-- ====================== to here ====================== -->
<script type="text/javascript">
    console.log(document.getElementById("planselect").value);
    /* ====================== INSERT JS HERE ====================== */

</script>
</body>
</html>

See also:

Where to place Javascript in a HTML file?

$(document).ready equivalent without jQuery


来源: stackexchange

问:
How to display Motion JPEG binary data stream with Angular/Ionic/JS?
I'm coding an app for a device, such device will receive a POST request, and send back a multipart/x-mixed-replace binary data stream. I must display such stream on one section of my app's home page.

I searched through, there's very limited resource on such case. So far, I found that if the Motion JPEG is sent from a specific URL, then maybe it's possible to use iframe/img tag to display it. However, my case is different, it seems I have to parse such binary stream then create an Observable to alter the img element on an image html tag once I get a frame from the Motion JPEG binary stream.

Is there a simpler way to do that ? I found https://gist.github.com/legege/5301477, can I use this ?

答:
I actually solved this by myself, and learned a lot in the research.

The core idea is to use a xmlHTTP request to fetch the motionJPEG data, It's about how to transfer binary data.

Then use a web worker to process the binary data.

And finally use canvas to draw the image on ionic page.

Due to the front end JS delay on image loading, such motionJPEG preview would not be so smooth currently in my implementation. But this is possible now with JS.

Please check github https://github.com/makoto-unity/ThetaWifiStreaming

ContentLicense: CC BY-SA 3.0


问:
Should I always use virtualenvs in Django?
I'm a beginner, and I'm learning Django for web development. So I want to know for my little test, should in always have a virtualenv or can I continue to learn without installing it? I've asked because in youtube Django videos, some instructors are installing it, and others aren't.</p>

答:
This is to some extent an opinion based question, but because it concerns good practices I'd like to drop few lines.

Some instructors in Django videos don't say anything about virtualenvs, maybe because their course aims at Django and not virtualenvs and their videos can't have it all.

It is generally a good practice to use virtual environments for Python, especially for web development. You'll start with some tutorial and use certain version of Django. For your next project, you'd like eventually to go with the latest or maybe the LTS version. Don't mess everything by installing packages globally as root.

Beyond virtualenv I'd strongly recommend using virtualenvwrapper, which makes the use of virtual environments a real pleasure.


问:
QML MenuItem Highlighted doesn't work
Please can someone explain me one thing. Suppose I have an item, if I click it, then a drop-down menu appears. How to make that when you hover over menu items, they stand out like that?

Code:

```<code>Rectangle {
    id: main_window
    width: 600
    height: 600
    property int mrg: 10

    Rectangle {
        anchors.centerIn: parent
        width: 500
        height: 500
        color: 'green'

        Text {
            id: field
            text: "Click!"
            font.pointSize: 20
            color: 'white'
            anchors.centerIn: parent

            MouseArea {
                id: ma
                anchors.fill: parent
                hoverEnabled: true

                onClicked: {
                    menu.x = ma.mouseX
                    menu.open()
                }
            }

            Menu {
                id: menu
                y: field.height
                MenuItem {
                    text: "Menu item"
                    highlighted: true

                }
            }
        }
    }
}
</code>```

In the documentation, I came across the point that the proper highlight is responsible for selecting the appropriate menu item. I installed it in the True, but it did not change anything.
Please tell me what I'm doing wrong. Thanks a lot.

答:
The default implementation of MenuItem doesn't include any visual highlighting feature, but you can adapt the graphical representation to your needs as explained in the Qt manuals. So, your MenuItem should look like this:

```<code>MenuItem {
    id: control
    text: "Menu item"

    background: Item {
        implicitWidth: 200
        implicitHeight: 40

        Rectangle {
            anchors.fill: parent
            anchors.margins: 1
            color: control.highlighted ? "blue" : "transparent" // blue background if the control is highlighed
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true // enable mouse enter events when no mouse buttons are pressed
                onContainsMouseChanged: control.highlighted = containsMouse // set the highlighted flag when the mouse hovers the MenuItem
            }
        }
    }
}
</code>```

Note that this implementation is based on the default implementation provided by Qt:

```<code>background: Item {
    implicitWidth: 200
    implicitHeight: 40

    Rectangle {
        x: 1
        y: 1
        width: parent.width - 2
        height: parent.height - 2
        color: control.visualFocus || control.down ? Default.delegateColor : "transparent"
    }
}
</code>```

Note that Bob's answer simplifies this solution by eliminating the MouseArea

Title: QML MenuItem Highlighted doesn't work

Body:
Please can someone explain me one thing. Suppose I have an item, if I click it, then a drop-down menu appears. How to make that when you hover over menu items, they stand out like that?

Code:

Rectangle {
    id: main_window
    width: 600
    height: 600
    property int mrg: 10

    Rectangle {
        anchors.centerIn: parent
        width: 500
        height: 500
        color: 'green'

        Text {
            id: field
            text: "Click!"
            font.pointSize: 20
            color: 'white'
            anchors.centerIn: parent

            MouseArea {
                id: ma
                anchors.fill: parent
                hoverEnabled: true

                onClicked: {
                    menu.x = ma.mouseX
                    menu.open()
                }
            }

            Menu {
                id: menu
                y: field.height
                MenuItem {
                    text: "Menu item"
                    highlighted: true

                }
            }
        }
    }
}

In the documentation, I came across the point that the proper highlight is responsible for selecting the appropriate menu item. I installed it in the True, but it did not change anything.
Please tell me what I'm doing wrong. Thanks a lot.

Body:
The default implementation of MenuItem doesn't include any visual highlighting feature, but you can adapt the graphical representation to your needs as explained in the Qt manuals. So, your MenuItem should look like this:

MenuItem {
    id: control
    text: "Menu item"

    background: Item {
        implicitWidth: 200
        implicitHeight: 40

        Rectangle {
            anchors.fill: parent
            anchors.margins: 1
            color: control.highlighted ? "blue" : "transparent" // blue background if the control is highlighed
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true // enable mouse enter events when no mouse buttons are pressed
                onContainsMouseChanged: control.highlighted = containsMouse // set the highlighted flag when the mouse hovers the MenuItem
            }
        }
    }
}

Note that this implementation is based on the default implementation provided by Qt:

background: Item {
    implicitWidth: 200
    implicitHeight: 40

    Rectangle {
        x: 1
        y: 1
        width: parent.width - 2
        height: parent.height - 2
        color: control.visualFocus || control.down ? Default.delegateColor : "transparent"
    }
}

Note that Bob's answer simplifies this solution by eliminating the MouseArea

ContentLicense: CC BY-SA 4.0


问:
Creating a Linked List of Odd Numbers (C)
I'm fairly new to coding and am taking a course at school that teaches the C programming language. We are learning about data structures in C and have been given an assignment which requires us to create a linked list with the odd integers from 1 to 10, and also print that list. However, the code that I have written seems to be having some problems. Here it is:

```<code>#include <stdio.h>
#include <stdlib.h>

struct listNode {
    int value;
    struct listNode *nextPtr;
};

typedef struct listNode ListNode;
typedef ListNode *ListNodePtr;

void createList(ListNodePtr *sPtr);
void printList(ListNodePtr currentPtr);

int main(void) {
    ListNodePtr list1Ptr;

    list1Ptr = NULL;

    list1Ptr->value = 1;
    createList(&list1Ptr);
    printf("List 1 is: ");
    printList(list1Ptr);

    printf("End of run.\n");

    return 0;
}

void createList(ListNodePtr *sPtr) {
    ListNodePtr previousPtr;
    ListNodePtr newPtr;

    newPtr = malloc(sizeof(ListNodePtr));

    if (newPtr != NULL) {
        newPtr = *sPtr;

        previousPtr = NULL;

        while (((*sPtr)->value) <= 10) {
            previousPtr = *sPtr;
            *sPtr = (*sPtr)->nextPtr;
            (*sPtr)->value = previousPtr->value + 2;
        }
    }
    else {
        printf("No memory available.\n");
    }
}

int isEmpty(ListNodePtr sPtr) {
    return sPtr == NULL;
}

void printList(ListNodePtr currentPtr) {
    if (currentPtr == NULL) {
        printf("List is empty.\n\n");
    }
    else {
        while (currentPtr != NULL) {
            printf("%d ", currentPtr->value);
            currentPtr = currentPtr->nextPtr;
        }
        printf("*\n");
    }
}
</code>```

The desired output it: [List 1 is: 1 3 5 7 9 *]
The environment I use keeps telling me that there are either "unhandled exceptions" (I'm not so sure what that means) or just ceases running midway. Any ideas of how I might be able to reach the desired outcome?

Any other tips and words of advice are greatly appreciated. Thank you!

答:
IMHO the most intuitive interface for such a constructor function is

use the function arguments to supply the parameters to the constructor

use the return value to pass the produced item(s) to the caller

```<code>struct listNode *listNode_generate(int start, int stop, int step)
{
struct listNode *result, **pp;

if (!step) return NULL;

result = NULL, pp = &result;

for (   ; start <= stop; start += step) {
        *pp = malloc (sizeof **pp);
        if (!*pp) break;
        (*pp)->value = start;
        pp = &(*pp)->next;
        }
*pp = NULL;
return result;
}
</code>```

To be called in main() like:

```<code>list1Ptr = listNode_generate(1,10,2);
</code>```

Body:
I'm fairly new to coding and am taking a course at school that teaches the C programming language. We are learning about data structures in C and have been given an assignment which requires us to create a linked list with the odd integers from 1 to 10, and also print that list. However, the code that I have written seems to be having some problems. Here it is:

#include <stdio.h>
#include <stdlib.h>

struct listNode {
    int value;
    struct listNode *nextPtr;
};

typedef struct listNode ListNode;
typedef ListNode *ListNodePtr;

void createList(ListNodePtr *sPtr);
void printList(ListNodePtr currentPtr);

int main(void) {
    ListNodePtr list1Ptr;

    list1Ptr = NULL;

    list1Ptr->value = 1;
    createList(&list1Ptr);
    printf("List 1 is: ");
    printList(list1Ptr);

    printf("End of run.\n");

    return 0;
}

void createList(ListNodePtr *sPtr) {
    ListNodePtr previousPtr;
    ListNodePtr newPtr;

    newPtr = malloc(sizeof(ListNodePtr));

    if (newPtr != NULL) {
        newPtr = *sPtr;

        previousPtr = NULL;

        while (((*sPtr)->value) <= 10) {
            previousPtr = *sPtr;
            *sPtr = (*sPtr)->nextPtr;
            (*sPtr)->value = previousPtr->value + 2;
        }
    }
    else {
        printf("No memory available.\n");
    }
}

int isEmpty(ListNodePtr sPtr) {
    return sPtr == NULL;
}

void printList(ListNodePtr currentPtr) {
    if (currentPtr == NULL) {
        printf("List is empty.\n\n");
    }
    else {
        while (currentPtr != NULL) {
            printf("%d ", currentPtr->value);
            currentPtr = currentPtr->nextPtr;
        }
        printf("*\n");
    }
}

The desired output it: [List 1 is: 1 3 5 7 9 *]
The environment I use keeps telling me that there are either "unhandled exceptions" (I'm not so sure what that means) or just ceases running midway. Any ideas of how I might be able to reach the desired outcome?

Any other tips and words of advice are greatly appreciated. Thank you!

Body:
IMHO the most intuitive interface for such a constructor function is

use the function arguments to supply the parameters to the constructor

use the return value to pass the produced item(s) to the caller

struct listNode *listNode_generate(int start, int stop, int step)
{
struct listNode *result, **pp;

if (!step) return NULL;

result = NULL, pp = &result;

for (   ; start <= stop; start += step) {
        *pp = malloc (sizeof **pp);
        if (!*pp) break;
        (*pp)->value = start;
        pp = &(*pp)->next;
        }
*pp = NULL;
return result;
}

To be called in main() like:

list1Ptr = listNode_generate(1,10,2);


问:
install gimp with homebrew?
I worked with gimp a while back when users had to install x11. I want to install it again for a project requiring image editing. I see there are a lot of enhancements to the installation process. It seems installing x11 is not required anymore. I am so used to brew everything. Is there a way to install gimp with homebrew? </p>

答:
I tried to install using @pat's answer. It did not work.
The solution provided by @Gianfranco is the only one that did work:

```<code>brew tap caskroom/cask
brew install Caskroom/cask/gimp
</code>```

The result is:

```<code>brew tap caskroom/cask

==> Tapping caskroom/cask
Cloning into '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask'...
remote: Counting objects: 3730, done.
remote: Compressing objects: 100% (3706/3706), done.
remote: Total 3730 (delta 39), reused 588 (delta 20), pack-reused 0
Receiving objects: 100% (3730/3730), 1.26 MiB | 1.39 MiB/s, done.
Resolving deltas: 100% (39/39), done.
Checking connectivity... done.
Tapped 0 formulae (3,738 files, 4.0MB)
</code>```

And:

```<code>brew install Caskroom/cask/gimp

==> brew cask install Caskroom/cask/gimp
==> Downloading https://download.gimp.org/pub/gimp/v2.8/osx/gimp-2.8.22-x86_64.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask gimp
==> Installing Cask gimp
==> Moving App 'GIMP.app' to '/Applications/GIMP.app'.
  gimp was successfully installed!
</code>```

Title: install gimp with homebrew?

Body:
I tried to install using @pat's answer. It did not work.
The solution provided by @Gianfranco is the only one that did work:

brew tap caskroom/cask
brew install Caskroom/cask/gimp

The result is:

brew tap caskroom/cask

==> Tapping caskroom/cask
Cloning into '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask'...
remote: Counting objects: 3730, done.
remote: Compressing objects: 100% (3706/3706), done.
remote: Total 3730 (delta 39), reused 588 (delta 20), pack-reused 0
Receiving objects: 100% (3730/3730), 1.26 MiB | 1.39 MiB/s, done.
Resolving deltas: 100% (39/39), done.
Checking connectivity... done.
Tapped 0 formulae (3,738 files, 4.0MB)

And:

brew install Caskroom/cask/gimp

==> brew cask install Caskroom/cask/gimp
==> Downloading https://download.gimp.org/pub/gimp/v2.8/osx/gimp-2.8.22-x86_64.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask gimp
==> Installing Cask gimp
==> Moving App 'GIMP.app' to '/Applications/GIMP.app'.
  gimp was successfully installed!


答:
There's no good reason not to that I know of, and speaking as someone who did not when I first started learning and messed up my system in such a way that it took months to fix, I'd highly recommend them.  You'll most likely be using them in whatever job you eventually get, so it's a good and easy thing to learn.

Virtualenv-burrito is a quick and easy way to get everything set up.

https://github.com/brainsik/virtualenv-burrito

Title: Should I always use virtualenvs in Django?

Body: I'm a beginner, and I'm learning Django for web development. So I want to know for my little test, should in always have a virtualenv or can I continue to learn without installing it? I've asked because in youtube Django videos, some instructors are installing it, and others aren't.


问:
How to access data outside onResponse?
I have no idea why medicine_description is returning null outside onResponse.

```<code>        StringRequest stringRequest = new StringRequest(Request.Method.GET, fda_api + "acetaminophen", new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {

                    JSONObject json = new JSONObject(response);
                    JSONArray jArray = json.getJSONArray("results");
                    Log.d(TAG, "readJSON: " + jArray.length());

                    JSONObject json_data = jArray.getJSONObject(0);
                    medicine_description = json_data.getString("description");
                    Log.i("THIS ONE IS FINE",medicine_description);
                    /*for(int i=0; i<jArray.length(); i++){
                        JSONObject json_data = jArray.getJSONObject(i);
                        medicine_description = json_data.getString("description");

                        Log.i("log_tag",medicine_description);
                    }*/
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        RequestQueue requestQueue = Volley.newRequestQueue(context);
        requestQueue.add(stringRequest);
        Log.i(TAG, "THIS RETURNS NULL: " + medicine_description);
</code>```

答: onResponse is invoked asynchronously when the Request is finished, hence after your logging output. The Request Queue doesn't block your current Thread.

Title: How to access data outside onResponse?

Body:
I have no idea why medicine_description is returning null outside onResponse.

        StringRequest stringRequest = new StringRequest(Request.Method.GET, fda_api + "acetaminophen", new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {

                    JSONObject json = new JSONObject(response);
                    JSONArray jArray = json.getJSONArray("results");
                    Log.d(TAG, "readJSON: " + jArray.length());

                    JSONObject json_data = jArray.getJSONObject(0);
                    medicine_description = json_data.getString("description");
                    Log.i("THIS ONE IS FINE",medicine_description);
                    /*for(int i=0; i<jArray.length(); i++){
                        JSONObject json_data = jArray.getJSONObject(i);
                        medicine_description = json_data.getString("description");

                        Log.i("log_tag",medicine_description);
                    }*/
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        RequestQueue requestQueue = Volley.newRequestQueue(context);
        requestQueue.add(stringRequest);
        Log.i(TAG, "THIS RETURNS NULL: " + medicine_description);


问:
How to debug webpacker running twice?
Rails 5.1.1, ruby 2.4.1, webpacker 2.0, when running system tests through rake test:system.

It will be helpful If there is way to see more debug logs, like which file load which modules, etc.

Note that It is happen only when there is no cache, that tests should be. If there is cache, webpacker does not run at all, which is normal.

```<code>/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/installers.rake:1: warning: already initialized constant INSTALLERS
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/installers.rake:1: warning: previous definition of INSTALLERS was here
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/webpacker/install.rake:1: warning: already initialized constant WEBPACKER_APP_TEMPLATE_PATH
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/webpacker/install.rake:1: warning: previous definition of WEBPACKER_APP_TEMPLATE_PATH was here
Webpacker is installed � �
Using ..../config/webpacker.yml file for setting up webpack paths
Webpacker is installed � �
Using ..../config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets �
[Webpacker] Compiling assets �
</code>```

答:
It turns out that rake task from webpacker is loading the Rakefile again.

https://github.com/rails/webpacker/pull/477/files

Title: How to debug webpacker running twice?

Body:
Rails 5.1.1, ruby 2.4.1, webpacker 2.0, when running system tests through rake test:system.

It will be helpful If there is way to see more debug logs, like which file load which modules, etc.

Note that It is happen only when there is no cache, that tests should be. If there is cache, webpacker does not run at all, which is normal.

/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/installers.rake:1: warning: already initialized constant INSTALLERS
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/installers.rake:1: warning: previous definition of INSTALLERS was here
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/webpacker/install.rake:1: warning: already initialized constant WEBPACKER_APP_TEMPLATE_PATH
/usr/local/lib/ruby/gems/2.4.0/gems/webpacker-2.0/lib/tasks/webpacker/install.rake:1: warning: previous definition of WEBPACKER_APP_TEMPLATE_PATH was here
Webpacker is installed � �
Using ..../config/webpacker.yml file for setting up webpack paths
Webpacker is installed � �
Using ..../config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets �
[Webpacker] Compiling assets �


问:
How to add a white line below every ListView Item in xml?
My Problem is --> I put a white line as a view in the Fragment item xml but it doesn't appear when i debug it. How can i get the changes i make in the fragment item xml file. Because i tried some little changes like alpha property change but it didnt change is it because of this is a listview and has itself design? Please help me about that problem.

The xml code and adapter code are below.

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical"
        android:gravity="center"
        android:paddingTop="5dp"
        >

        <ImageView
            android:id="@+id/menulogo"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@drawable/infoicon"
            android:layout_gravity="center"
            android:paddingTop="5dp"
            />

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="vertical"
        android:gravity="center">
        <TextView
            android:id="@+id/txtMenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="Company Name"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_weight="1" />
    </LinearLayout>
    <View
        android:id="@+id/line"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:layout_below="@+id/txtMenu"
        android:background="#FFFFFF"
        />

</LinearLayout>
</code>```

My listview adapter codes right down below.

```<code>    public class MenuListAdapter extends ArrayAdapter<Menu_Item> {
        private final ArrayList<Menu_Item> list;
        private final Activity context;
    private int[] colors = new int[]{0x34a4a4a4, 0x34fafafa};

    public MenuListAdapter(Activity context, ArrayList<Menu_Item> list) {
        super(context, R.layout.menu_item, list);
        this.context = context;
        this.list = list;
    }

    static class ViewHolder {
        public ImageView menulogo;
        public TextView txtMenu;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            view = inflator.inflate(R.layout.menu_item, null);
            final ViewHolder viewHolder = new ViewHolder();
            viewHolder.menulogo = (ImageView) view.findViewById(R.id.menulogo);
            viewHolder.txtMenu = (TextView) view.findViewById(R.id.txtMenu);
            view.setTag(viewHolder);
            int colorPos = position % colors.length;
            view.setBackgroundColor(colors[colorPos]);
        } else {
            view = convertView;
        }
        ViewHolder holder = (ViewHolder) view.getTag();
        holder.txtMenu.setText(list.get(position).getMenuName());
        //holder.menulogo.setImageBitmap(list.get(position).getMenuImage());
        String menuName=list.get(position).getMenuName();
        if (menuName.equals("Info")){
            holder.menulogo.setImageResource(R.drawable.infoicon);
        }
        if (menuName.equals("Odalar")){
            holder.menulogo.setImageResource(R.drawable.accomodation);
        }
        if (menuName.equals("Galeri")){
            holder.menulogo.setImageResource(R.drawable.galeryicon);
        }
        if (menuName.equals("Aktiviteler")){
            holder.menulogo.setImageResource(R.drawable.activitiesicon);
        }
        if (menuName.equals("Robin's Kids Club")){
            holder.menulogo.setImageResource(R.drawable.kidsclub);
        }
        if (menuName.equals("Restaurants")){
            holder.menulogo.setImageResource(R.drawable.restaurantsicon);
        }
        view.setId(list.get(position).getMenu_id());
        return view;
    }

    @Override
    public int getViewTypeCount() {
        if (getCount() != 0)
            return getCount();

        return 1;
    }

    }
</code>```

答:
I found an answer to my question and wanted to share it with you.

I only used these 2 properties below of ListView

```<code>android:divider="#FFFFFF"
android:dividerHeight="1dip"
</code>```

Like this...

```<code> <ListView
    android:id="@+id/menuList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:divider="#FFFFFF"
    android:dividerHeight="1dip"
    />
</code>```

Body:
My Problem is --> I put a white line as a view in the Fragment item xml but it doesn't appear when i debug it. How can i get the changes i make in the fragment item xml file. Because i tried some little changes like alpha property change but it didnt change is it because of this is a listview and has itself design? Please help me about that problem.

The xml code and adapter code are below.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical"
        android:gravity="center"
        android:paddingTop="5dp"
        >

        <ImageView
            android:id="@+id/menulogo"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@drawable/infoicon"
            android:layout_gravity="center"
            android:paddingTop="5dp"
            />

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="vertical"
        android:gravity="center">
        <TextView
            android:id="@+id/txtMenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="Company Name"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_weight="1" />
    </LinearLayout>
    <View
        android:id="@+id/line"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:layout_below="@+id/txtMenu"
        android:background="#FFFFFF"
        />

</LinearLayout>

My listview adapter codes right down below.

    public class MenuListAdapter extends ArrayAdapter<Menu_Item> {
        private final ArrayList<Menu_Item> list;
        private final Activity context;
    private int[] colors = new int[]{0x34a4a4a4, 0x34fafafa};

    public MenuListAdapter(Activity context, ArrayList<Menu_Item> list) {
        super(context, R.layout.menu_item, list);
        this.context = context;
        this.list = list;
    }

    static class ViewHolder {
        public ImageView menulogo;
        public TextView txtMenu;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if (convertView == null) {
            LayoutInflater inflator = context.getLayoutInflater();
            view = inflator.inflate(R.layout.menu_item, null);
            final ViewHolder viewHolder = new ViewHolder();
            viewHolder.menulogo = (ImageView) view.findViewById(R.id.menulogo);
            viewHolder.txtMenu = (TextView) view.findViewById(R.id.txtMenu);
            view.setTag(viewHolder);
            int colorPos = position % colors.length;
            view.setBackgroundColor(colors[colorPos]);
        } else {
            view = convertView;
        }
        ViewHolder holder = (ViewHolder) view.getTag();
        holder.txtMenu.setText(list.get(position).getMenuName());
        //holder.menulogo.setImageBitmap(list.get(position).getMenuImage());
        String menuName=list.get(position).getMenuName();
        if (menuName.equals("Info")){
            holder.menulogo.setImageResource(R.drawable.infoicon);
        }
        if (menuName.equals("Odalar")){
            holder.menulogo.setImageResource(R.drawable.accomodation);
        }
        if (menuName.equals("Galeri")){
            holder.menulogo.setImageResource(R.drawable.galeryicon);
        }
        if (menuName.equals("Aktiviteler")){
            holder.menulogo.setImageResource(R.drawable.activitiesicon);
        }
        if (menuName.equals("Robin's Kids Club")){
            holder.menulogo.setImageResource(R.drawable.kidsclub);
        }
        if (menuName.equals("Restaurants")){
            holder.menulogo.setImageResource(R.drawable.restaurantsicon);
        }
        view.setId(list.get(position).getMenu_id());
        return view;
    }

    @Override
    public int getViewTypeCount() {
        if (getCount() != 0)
            return getCount();

        return 1;
    }

    }

Body:
I found an answer to my question and wanted to share it with you.

I only used these 2 properties below of ListView

android:divider="#FFFFFF"
android:dividerHeight="1dip"

Like this...

 <ListView
    android:id="@+id/menuList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:divider="#FFFFFF"
    android:dividerHeight="1dip"
    />


问:
Stored data set from stored procedure - Execute SQL Task
I have this stored procedure:

```<code>Dbo.SprocName (@Id UNIQUEIDENTIFIER,
               @ResponseCode INT OUTPUT,
               @ResponseDescription VARCHAR(500) OUTPUT)
</code>```

And it returns a dataset called say Result as a nvarchar(MAX) (always a single row).

I've tried OLE and ADO connections and as well as result sets. I've tried creating a table variable and storing the value there.

Nothing works.

I can see in the database that it's running successfully then it fails when returning the result data set.

I’ve done some debugging and I can assure the result string is returned as should be. The problem is that I don’t know how to handle this on SSIS.

The error that I get is:

Input string was not in a correct format

I appreciate any ideas.

Thanks.

EDIT: I have tried using a table variable again and it works. I guess I didn't do it well first time. sorry about that. Thanks!

答:
One potential cause for your problem could be a mismatch in data types between SSIS and SQL Server.

An SSIS GUID data type does not match a SQL Server uniqueidentifier - the SSIS GUID has curly braces (e.g., {00000000-0000-0000-0000-000000000000}), while the SQL value does not. SQL cannot recognize the value as a unique identifier, and fails to convert.

To pass down a GUID, you will need to remove those curly braces, either in SSIS or in SQL.  One approach I've used it to send it across as a VARCHAR and then strip out the curly braces, e.g.,

```<code>DECLARE @GUID VARCHAR(40) = '{00000000-0000-0000-0000-000000000000}'
DECLARE @CnvtGUID UNIQUEIDENTIFIER = REPLACE(REPLACE(@GUID, '}', ''), '{', '')

SELECT @GUID, @CnvtGUID
</code>```

Body:
I have this stored procedure:

Dbo.SprocName (@Id UNIQUEIDENTIFIER,
               @ResponseCode INT OUTPUT,
               @ResponseDescription VARCHAR(500) OUTPUT)

And it returns a dataset called say Result as a nvarchar(MAX) (always a single row).

I've tried OLE and ADO connections and as well as result sets. I've tried creating a table variable and storing the value there.

Nothing works.

I can see in the database that it's running successfully then it fails when returning the result data set.

I’ve done some debugging and I can assure the result string is returned as should be. The problem is that I don’t know how to handle this on SSIS.

The error that I get is:

Input string was not in a correct format

I appreciate any ideas.

Thanks.

EDIT: I have tried using a table variable again and it works. I guess I didn't do it well first time. sorry about that. Thanks!

Body:
One potential cause for your problem could be a mismatch in data types between SSIS and SQL Server.

An SSIS GUID data type does not match a SQL Server uniqueidentifier - the SSIS GUID has curly braces (e.g., {00000000-0000-0000-0000-000000000000}), while the SQL value does not. SQL cannot recognize the value as a unique identifier, and fails to convert.

To pass down a GUID, you will need to remove those curly braces, either in SSIS or in SQL.  One approach I've used it to send it across as a VARCHAR and then strip out the curly braces, e.g.,

DECLARE @GUID VARCHAR(40) = '{00000000-0000-0000-0000-000000000000}'
DECLARE @CnvtGUID UNIQUEIDENTIFIER = REPLACE(REPLACE(@GUID, '}', ''), '{', '')

SELECT @GUID, @CnvtGUID


问:
How to show folder of folder as a list in UITableView - Swift
I am making an application that have a lot of static data. The data consists of images and text (each text file consists of multiple strings), and it will be hundres of items. I have the folders sorted in this way:

```<code>- Category
- - Name 1
- - - Image1.png, text1.strings
- - Name 2
- - - Image2.png, text2.strings
</code>```

Then i want to show each folder of the category as its own row in a tableview. Is this a bad way to do it, any other preferred way to do it? If not how do you do this in Xcode with Swift?

Also would it be possible to make this searchable in the future?

答:
```<code>cell.indentationLevel = 1 // Your indentation level
</code>```

UPDATE

```<code>    @IBOutlet weak var tblView: UITableView!

    let tblData:[[String:Any]] = [["title":"Category", "indentationLevel":0],
                                  ["title":"Name 1", "indentationLevel":1],
                                  ["title":"Image1.png", "indentationLevel":2],
                                  ["title":"Name 2", "indentationLevel":1],
                                  ["title":"Image2.png", "indentationLevel":2]]

    // UITableView delegate methods
    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tblData.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell  = tableView.dequeueReusableCell(withIdentifier: "cell")

        cell?.textLabel?.text = tblData[indexPath.row]["title"] as? String ?? "NA"
        cell?.indentationWidth = 10
        cell?.indentationLevel = tblData[indexPath.row]["indentationLevel"] as? Int ?? 0

        return cell!

    }
</code>```

NOTE:

You can use plist to store your static data instead of array of dictionary

Body:
I am making an application that have a lot of static data. The data consists of images and text (each text file consists of multiple strings), and it will be hundres of items. I have the folders sorted in this way:

- Category
- - Name 1
- - - Image1.png, text1.strings
- - Name 2
- - - Image2.png, text2.strings

Then i want to show each folder of the category as its own row in a tableview. Is this a bad way to do it, any other preferred way to do it? If not how do you do this in Xcode with Swift?

Also would it be possible to make this searchable in the future?

Body:
cell.indentationLevel = 1 // Your indentation level

UPDATE

    @IBOutlet weak var tblView: UITableView!

    let tblData:[[String:Any]] = [["title":"Category", "indentationLevel":0],
                                  ["title":"Name 1", "indentationLevel":1],
                                  ["title":"Image1.png", "indentationLevel":2],
                                  ["title":"Name 2", "indentationLevel":1],
                                  ["title":"Image2.png", "indentationLevel":2]]

    // UITableView delegate methods
    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tblData.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell  = tableView.dequeueReusableCell(withIdentifier: "cell")

        cell?.textLabel?.text = tblData[indexPath.row]["title"] as? String ?? "NA"
        cell?.indentationWidth = 10
        cell?.indentationLevel = tblData[indexPath.row]["indentationLevel"] as? Int ?? 0

        return cell!

    }

NOTE:

You can use plist to store your static data instead of array of dictionary


问:
Export & Import syntax error with node =>4.6.x
Node supports ES6 from node v4.6 upwards, if i'm not mistaken.
Creating ES6 modules works fine until I need to import and export these modules, I then get the following error(s):

```<code>export class Helper {
^^^^^^
SyntaxError: Unexpected token export
</code>```

I feel like I'm missing something.

SOLUTION THAT WORKED FOR ME

in your tsconfig.json file, add the property

```<code>{"module": "commonjs"}
</code>```

this will keep the ES6 syntax and behaviour but import/export using the ES5 method.

答:
This is what you would want:</p>

```<code>class name {

 }

module.exports = name;
</code>```

Body:
Node supports ES6 from node v4.6 upwards, if i'm not mistaken.
Creating ES6 modules works fine until I need to import and export these modules, I then get the following error(s):

export class Helper {
^^^^^^
SyntaxError: Unexpected token export

I feel like I'm missing something.

SOLUTION THAT WORKED FOR ME

in your tsconfig.json file, add the property

{"module": "commonjs"}

this will keep the ES6 syntax and behaviour but import/export using the ES5 method.

Body:
This is what you would want:

class name {

 }

module.exports = name;


问:
onchange="" doesn't work in select tag
I have two tags of select. Their IDs is "study-phase" and "study-year".
I want when the value of study phase to process a CSS code.

HTML:

```<code><select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select>
<style type="text/css">
    #a , #b , #c , #d , #f , #g , #h , #j , #k , #e , #i {
        display: none;
    }
</style>
</code>```

JS:

```<code>$(function(myFunction()){
   if (document.getElementById("study-phase").value == "pri") {
       document.getElementById("a").style.display = "block";
   }
});
</code>```

And after run the code the css code which I  want don't launch.
What's the problem here ?

答:
Your JavaScript isn't valid.

Moreover, I think you want to one of the option in the second dropdown once you make change in the first.

You can build on this logic further

Here is a sample minimal code:

function myFunction() {

  if (document.getElementById("study-phase").value == "pri")
    document.getElementById("study-year").value = "aa";
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select></code>```

Title: onchange="" doesn't work in select tag

Body:
I have two tags of select. Their IDs is "study-phase" and "study-year".
I want when the value of study phase to process a CSS code.

HTML:

<select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select>

JS:

$(function(myFunction()){
   if (document.getElementById("study-phase").value == "pri") {
       document.getElementById("a").style.display = "block";
   }
});

And after run the code the css code which I  want don't launch.
What's the problem here ?

Body:
Your JavaScript isn't valid.

Moreover, I think you want to one of the option in the second dropdown once you make change in the first.

You can build on this logic further

Here is a sample minimal code:

function myFunction() {

  if (document.getElementById("study-phase").value == "pri")
    document.getElementById("study-year").value = "aa";
};

<select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select>


问:
Write dictionnary with tuple containing parameters as unique value for features into postgresql table
In Python 2.7, let a dictionary with features' IDs as keys.

There are thousands of features.

Each feature has a single value, but this value is a tuple containing 6 parameters for the features (for example; size, color, etc.)

On the other hand I have a postgreSQL table in a database where these features parameters must be saved.

The features' IDs  are already set in the table (as well as other informations about these features).

The IDs are unique (they are random (thus not serial) but unique numbers).

There is 6 empty columns with names: "param1", "param2", "param3", ..., "param6".

I already have a tuple containing these names:

```<code>columns = ("param1", "param2", "param3", ..., "param6")
</code>```

The code I have doesn't work for saving these parameters in their respective columns for each feature:

```<code># "view" is the dictionary with features's ID as keys()
# and their 6 params stored in values().
values  = [view[i] for i in view.keys()]
columns =  ("param1","param2","param3","param4","param5","param6")

conn = psycopg2.connect("dbname=mydb user=username password=password")
curs = conn.cursor()

curs.execute("DROP TABLE IF EXISTS mytable;")
curs.execute("CREATE TABLE IF NOT EXISTS mytable (LIKE originaltable including defaults including constraints including indexes);")
curs.execute("INSERT INTO mytable SELECT * from originaltable;")

insertstatmnt  = 'INSERT INTO mytable (%s) values %s'
alterstatement = ('ALTER TABLE mytable '+
                  'ADD COLUMN param1 text,'+
                  'ADD COLUMN param2 text,'+
                  'ADD COLUMN param3 real,'+
                  'ADD COLUMN param4 text,'+
                  'ADD COLUMN param5 text,'+
                  'ADD COLUMN param6 text;'
                  )
curs.execute(alterstatement) # It's working up to this point.
curs.execute(insertstatmnt, (psycopg2.extensions.AsIs(','.join(columns)), tuple(values))) # The problem seems to be here.

conn.commit() # Making change to DB !
curs.close()
conn.close()
</code>```

Here's the error I have:

```<code>curs.execute(insert_statement, (psycopg2.extensions.AsIs(','.join(columns)), tuple(values)))

ProgrammingError: INSERT has more expressions than target columns
</code>```

I must miss something.

How to do that properly?

答:
When using '%s' to get the statement as what I think you want, you just need to change a couple things.

Ignoring c.execute(), this statement is by no means wrong, but it does not return what you are looking for. Using my own version, this is what I got with that statement. I also ignored psycopg2.extensions.AsIs() because, it  is just a Adapter conform to the ISQLQuote protocol useful for objects whose string representation is already valid as SQL representation.

```<code>>>> values = [ i for i in range(0,5)] #being I dont know the keys, I just made up values.

>>> insertstatmnt, (','.join(columns), tuple(vlaues))
>>> ('INSERT INTO mytable (%s) values %s', ('param1,param2,param3,param4,param5,param6', (0, 1, 2, 3, 4)))
</code>```

As you can see, what you entered returns a tuple with the values.

```<code>>>> insertstatmnt % (','.join(columns), tuple(values))
>>> 'INSERT INTO mytable (param1,param2,param3,param4,param5,param6) values (0, 1, 2, 3, 4)'
</code>```

Where as, this returns a string that is more likely to be read by the SQL. The values obviously do not match the specified ones. I believe the problem you have lies within creating your string.

Reference for pycopg2: http://initd.org/psycopg/docs/extensions.html

Body:
In Python 2.7, let a dictionary with features' IDs as keys.

There are thousands of features.

Each feature has a single value, but this value is a tuple containing 6 parameters for the features (for example; size, color, etc.)

On the other hand I have a postgreSQL table in a database where these features parameters must be saved.

The features' IDs  are already set in the table (as well as other informations about these features).

The IDs are unique (they are random (thus not serial) but unique numbers).

There is 6 empty columns with names: "param1", "param2", "param3", ..., "param6".

I already have a tuple containing these names:

columns = ("param1", "param2", "param3", ..., "param6")

The code I have doesn't work for saving these parameters in their respective columns for each feature:

# "view" is the dictionary with features's ID as keys()
# and their 6 params stored in values().
values  = [view[i] for i in view.keys()]
columns =  ("param1","param2","param3","param4","param5","param6")

conn = psycopg2.connect("dbname=mydb user=username password=password")
curs = conn.cursor()

curs.execute("DROP TABLE IF EXISTS mytable;")
curs.execute("CREATE TABLE IF NOT EXISTS mytable (LIKE originaltable including defaults including constraints including indexes);")
curs.execute("INSERT INTO mytable SELECT * from originaltable;")

insertstatmnt  = 'INSERT INTO mytable (%s) values %s'
alterstatement = ('ALTER TABLE mytable '+
                  'ADD COLUMN param1 text,'+
                  'ADD COLUMN param2 text,'+
                  'ADD COLUMN param3 real,'+
                  'ADD COLUMN param4 text,'+
                  'ADD COLUMN param5 text,'+
                  'ADD COLUMN param6 text;'
                  )
curs.execute(alterstatement) # It's working up to this point.
curs.execute(insertstatmnt, (psycopg2.extensions.AsIs(','.join(columns)), tuple(values))) # The problem seems to be here.

conn.commit() # Making change to DB !
curs.close()
conn.close()

Here's the error I have:

curs.execute(insert_statement, (psycopg2.extensions.AsIs(','.join(columns)), tuple(values)))

ProgrammingError: INSERT has more expressions than target columns

I must miss something.

How to do that properly?

Body:
When using '%s' to get the statement as what I think you want, you just need to change a couple things.

Ignoring c.execute(), this statement is by no means wrong, but it does not return what you are looking for. Using my own version, this is what I got with that statement. I also ignored psycopg2.extensions.AsIs() because, it  is just a Adapter conform to the ISQLQuote protocol useful for objects whose string representation is already valid as SQL representation.

>>> values = [ i for i in range(0,5)] #being I dont know the keys, I just made up values.

>>> insertstatmnt, (','.join(columns), tuple(vlaues))
>>> ('INSERT INTO mytable (%s) values %s', ('param1,param2,param3,param4,param5,param6', (0, 1, 2, 3, 4)))

As you can see, what you entered returns a tuple with the values.

>>> insertstatmnt % (','.join(columns), tuple(values))
>>> 'INSERT INTO mytable (param1,param2,param3,param4,param5,param6) values (0, 1, 2, 3, 4)'

Where as, this returns a string that is more likely to be read by the SQL. The values obviously do not match the specified ones. I believe the problem you have lies within creating your string.

Reference for pycopg2: http://initd.org/psycopg/docs/extensions.html


答:
```<code>$(function(myFunction()){
    if (document.getElementById("study-phase").value == "pri") {
        document.getElementById("a").style.display = "block";
    }});
</code>```

give error

```<code>Uncaught SyntaxError: Unexpected token (
</code>```

apart if you revised your code as below it works, as it is vanillaJs you dont need jquery

function myFunction() {
  if (document.getElementById("study-phase").value == "pri") {
    document.getElementById("a").style.display = "block";
  }
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select>
<style type="text/css">
  #a,
  #b,
  #c,
  #d,
  #f,
  #g,
  #h,
  #j,
  #k,
  #e,
  #i {
    display: none;
  }
</style></code>```

Title: onchange="" doesn't work in select tag

Body:
$(function(myFunction()){
    if (document.getElementById("study-phase").value == "pri") {
        document.getElementById("a").style.display = "block";
    }});

give error

Uncaught SyntaxError: Unexpected token (

apart if you revised your code as below it works, as it is vanillaJs you dont need jquery

function myFunction() {
  if (document.getElementById("study-phase").value == "pri") {
    document.getElementById("a").style.display = "block";
  }
};

<select name="study-phase" onchange="myFunction()" id="study-phase" class="sp-input">
    <option value=""></option>
    <option id="pri" value="pri">Primary</option>
    <option id="pre" value="pre">Prep</option>
    <option id="sec" value="sec">Secondary</option>
</select>
<select name="study-year" id="study-year" class="sp-input">
    <option value=""></option>
    <option id="a" value="aa">Grade 1</option>
    <option id="b" value="">Grade 2</option>
    <option id="c" value="">Grade 3</option>
    <option id="d" value="">Grade 4</option>
    <option id="e" value="">Grade 5</option>
    <option id="f" value="">Grade 6</option>
    <option id="g" value="">Grade 7</option>
    <option id="h" value="">Grade 8</option>
    <option id="i" value="">Grade 9</option>
    <option id="j" value="">Grade 10</option>
</select>
<style type="text/css">
  #a,
  #b,
  #c,
  #d,
  #f,
  #g,
  #h,
  #j,
  #k,
  #e,
  #i {
    display: none;
  }
</style>


问:
How get href with a special src in child div in Python Scrapy
For getting all images of a site I write this code:

```<code>content = Selector(text = html)
all_images= content.css('img')
i = 0

for image in all_images:
    src =  image.css("::attr('src')").extract_first()
</code>```

After getting the src of image, now I want to have the href of each image

```<code><a href="/rayons/images" onclick="ga('send', 'event', 'computer HP', 'htwe', 'ope_xxl_s22Englos');">
    <img src="/mySrc/" alt="something" class="ze-content">
</a>
</code>```

How can I get href when I know the Src ?

答:
AFAIK, you can't do parent searches using CSS. In this case, XPath is a better fit. You could do this:

```<code>for image in all_images:
    src =  image.css("::attr('src')").extract_first()
    href = image.xpath('parent::a/@href').extract_first()
</code>```

Or, using XPath's abbreviated syntax:

```<code>href = image.xpath('../@href').extract_first()
</code>```

Body:
For getting all images of a site I write this code:

content = Selector(text = html)
all_images= content.css('img')
i = 0

for image in all_images:
    src =  image.css("::attr('src')").extract_first()

After getting the src of image, now I want to have the href of each image

How can I get href when I know the Src ?

Body:
AFAIK, you can't do parent searches using CSS. In this case, XPath is a better fit. You could do this:

for image in all_images:
    src =  image.css("::attr('src')").extract_first()
    href = image.xpath('parent::a/@href').extract_first()

Or, using XPath's abbreviated syntax:

href = image.xpath('../@href').extract_first()


问:
Env variables with Jelastic Spring Boot
I'm using the new Spring Boot node in Jelastic.

Previously under a Tomcat node I had;

```<code>server/variables.conf
-Dspring.profiles.active=sandbox
</code>```

Now under the Spring Boot node the default is;

```<code>conf/variables.conf
export JAVA_OPTS="-Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"
</code>```

Question is, where do I put my "-Dspring.profiles.active=sandbox"?

Adding it into the export line like so doesn't seem to work?

```<code>conf/variables.conf
export JAVA_OPTS="-Dspring.profiles.active=sandbox -Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"
</code>```

Nor on a line of its own.
Ideas?

答:
Ah figured it out; some shells don't allow dots!

So solution now looks like;

```<code>conf/variables.conf
export JAVA_OPTS="-Dspring.profiles.active=sandbox -Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"
export SPRING_PROFILES_ACTIVE=sandbox
</code>```

Title: Env variables with Jelastic Spring Boot

Body:
I'm using the new Spring Boot node in Jelastic.

Previously under a Tomcat node I had;

server/variables.conf
-Dspring.profiles.active=sandbox

Now under the Spring Boot node the default is;

conf/variables.conf
export JAVA_OPTS="-Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"

Question is, where do I put my "-Dspring.profiles.active=sandbox"?

Adding it into the export line like so doesn't seem to work?

conf/variables.conf
export JAVA_OPTS="-Dspring.profiles.active=sandbox -Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"

Nor on a line of its own.
Ideas?

Body:
Ah figured it out; some shells don't allow dots!

So solution now looks like;

conf/variables.conf
export JAVA_OPTS="-Dspring.profiles.active=sandbox -Xms32M -Xmn30M -Xmx1638M -Xminf0.1 -Xmaxf0.3  -XX:+UseG1GC -XX:+UseCompressedOops"
export SPRING_PROFILES_ACTIVE=sandbox


问:
jQuery scroll to anchor returns NaN as location hash
Friends,

I'm using following jQuery code which implements the animated scroll to an anchor:

```<code>(function($){
var jump=function(e)
{
    if (e){
        e.preventDefault();
        var target = $(this).attr("href");
    }else{
        var target = location.hash;
    }
    $('html,body').animate(
        {
            scrollTop: $(target).offset().top - 150
        }, 1500, 'swing', function()
        {
            location.hash = target - 150;
        });
};
$('html, body').hide();
$(document).ready(function()
{
    $('a[href^=#]:not(#toggle)').on("click", jump);
    if (location.hash){
        setTimeout(function(){
            $('html, body').scrollTop(0).show();
            jump()
        }, 0);
    }else{
        $('html, body').show()
    }
});
})(jQuery);
</code>```

As you see from the code above, I use the target offset value of 150px:

```<code>scrollTop: $(target).offset().top - 150
</code>```

In order for this code to work properly, I also need to pass the target with offset to the location.hash. This is how I do that:

```<code>location.hash = target - 150;
</code>```

Under such implementation, the code works fine. Except it always show #NaN in the URL when I scroll to anchor. This is clearly because of the line above. However, if I don't use the -150px, then it scrolls to target with offset and then suddenly jumps to original anchor location without offset.

My question is, how I can achieve both win win situation? I mean, no #NaN in URL and proper scroll to anchor with offset from top.  I heard that it's possible to use "e.preventdefault", but somehow it doesn't work for me.

Any suggestions would be very appreciated.

答:
Try

```<code>$('html,body').animate(
    {
        scrollTop: $(target).offset().top - 150
    }, 1500, 'swing');
location.hash = target;
};
</code>```

I had the same problem and now it works

Body:
Friends,

I'm using following jQuery code which implements the animated scroll to an anchor:

(function($){
var jump=function(e)
{
    if (e){
        e.preventDefault();
        var target = $(this).attr("href");
    }else{
        var target = location.hash;
    }
    $('html,body').animate(
        {
            scrollTop: $(target).offset().top - 150
        }, 1500, 'swing', function()
        {
            location.hash = target - 150;
        });
};
$('html, body').hide();
$(document).ready(function()
{
    $('a[href^=#]:not(#toggle)').on("click", jump);
    if (location.hash){
        setTimeout(function(){
            $('html, body').scrollTop(0).show();
            jump()
        }, 0);
    }else{
        $('html, body').show()
    }
});
})(jQuery);

As you see from the code above, I use the target offset value of 150px:

scrollTop: $(target).offset().top - 150

In order for this code to work properly, I also need to pass the target with offset to the location.hash. This is how I do that:

location.hash = target - 150;

Under such implementation, the code works fine. Except it always show #NaN in the URL when I scroll to anchor. This is clearly because of the line above. However, if I don't use the -150px, then it scrolls to target with offset and then suddenly jumps to original anchor location without offset.

My question is, how I can achieve both win win situation? I mean, no #NaN in URL and proper scroll to anchor with offset from top.  I heard that it's possible to use "e.preventdefault", but somehow it doesn't work for me.

Any suggestions would be very appreciated.

Body:
Try

$('html,body').animate(
    {
        scrollTop: $(target).offset().top - 150
    }, 1500, 'swing');
location.hash = target;
};

I had the same problem and now it works


问:
Failed to load resource, error 404, running with IIS Local
Good morning, I developed a mvc 5 application, during development I used IIS Express, all the files there loaded perfectly, when I uploaded to my IIS Local (7) still on my machine to test, I realized that several files are not loaded.

```<code>Failed to load resource: the server responded with a status of 404 (Not Found)
glyphicons-halflings-regular.woff
</code>```

When checking I identified that the file is not loaded because in fact, the path that tries to perform the GET is incorrect. It tries to get get on the path:

```<code>http://localhost/content/fonts/glyphicons-halflings-regular.woff
</code>```

But the correct file would be:

```<code>http://localhost/aprovacoes/content/fonts/glyphicons-halflings-regular.woff
</code>```

In the get, the project name is missing, due to this it is not loaded.

To solve the problem of this particular source, I needed to edit the bootstrap.min.css file and change the url from url:

```<code>url(/content/fonts/glyphicons-halflings-regular.woff)
</code>```

for

```<code>url(aprovacoes/content/fonts/glyphicons-halflings-regular.woff)
</code>```

However in every project several files are not loaded, and to solve I'm editing the css file by file, would not there be another way to map this correct path in all css files?

Thank you very much in advance

答:
Use a resource-relative path. For example, if you have a file structure like:

```<code>+ bootstrap.css
- fonts
    + glyphicons-halflings-regular.woff
</code>```

Then, use the URL: fonts/glyphicons-halflings-regular.woff. Or if it's something like:

```<code>- css
    + bootstrap.css
- fonts
    + glyphicons-halflings-regular.woff
</code>```

Then, you'd use: ../fonts/glyphicons-halflings-regular.woff.

That way, it won't matter how or where the site is deployed, as long as the relative path between the files remains consistent.

Body:
Good morning, I developed a mvc 5 application, during development I used IIS Express, all the files there loaded perfectly, when I uploaded to my IIS Local (7) still on my machine to test, I realized that several files are not loaded.

Failed to load resource: the server responded with a status of 404 (Not Found)
glyphicons-halflings-regular.woff

When checking I identified that the file is not loaded because in fact, the path that tries to perform the GET is incorrect. It tries to get get on the path:

http://localhost/content/fonts/glyphicons-halflings-regular.woff

But the correct file would be:

http://localhost/aprovacoes/content/fonts/glyphicons-halflings-regular.woff

In the get, the project name is missing, due to this it is not loaded.

To solve the problem of this particular source, I needed to edit the bootstrap.min.css file and change the url from url:

url(/content/fonts/glyphicons-halflings-regular.woff)

for

url(aprovacoes/content/fonts/glyphicons-halflings-regular.woff)

However in every project several files are not loaded, and to solve I'm editing the css file by file, would not there be another way to map this correct path in all css files?

Thank you very much in advance

Body:
Use a resource-relative path. For example, if you have a file structure like:

+ bootstrap.css
- fonts
    + glyphicons-halflings-regular.woff

Then, use the URL: fonts/glyphicons-halflings-regular.woff. Or if it's something like:

- css
    + bootstrap.css
- fonts
    + glyphicons-halflings-regular.woff

Then, you'd use: ../fonts/glyphicons-halflings-regular.woff.

That way, it won't matter how or where the site is deployed, as long as the relative path between the files remains consistent.


问:
Generating IDs for pie-like wedges (geometry) in PostgreSQL/PostGIS
I have a query that generates 12 sections (pie-like wedges) in a circle (buffer) of 50 meters around point layer.

```<code>With buffer as(
SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
FROM my_point_table group by gid, geom
UNION ALL
SELECT gid as pt_id, geom FROM my_point_table
)
SELECT gid, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM buffer
GROUP BY pt_id
</code>```

I would like to assign IDs to these sections like this:

Suggestions on how to do this would be highly appreciated.

答:
You can try something like this

```<code>With my_point_table as (
    select 1 as gid, 'POINT(0 0)'::geometry as geom
    union
    select 2 as gid, 'POINT(1 1)'::geometry as geom
), buffer as(
    SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
    FROM my_point_table group by gid, geom
    UNION ALL
    SELECT gid as pt_id, geom FROM my_point_table
) , tr as (
    SELECT pt_id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
    FROM buffer
    GROUP BY pt_id
)
select row_number() OVER (partition by pt_id), pt_id, geom from tr
</code>```

First part is to mock your "my_point_table" table.

row_number() OVER (partition by pt_id)
is what generates a sequential number for each feature.

Body:
I have a query that generates 12 sections (pie-like wedges) in a circle (buffer) of 50 meters around point layer.

With buffer as(
SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
FROM my_point_table group by gid, geom
UNION ALL
SELECT gid as pt_id, geom FROM my_point_table
)
SELECT gid, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM buffer
GROUP BY pt_id

I would like to assign IDs to these sections like this:

Suggestions on how to do this would be highly appreciated.

Body:
You can try something like this

With my_point_table as (
    select 1 as gid, 'POINT(0 0)'::geometry as geom
    union
    select 2 as gid, 'POINT(1 1)'::geometry as geom
), buffer as(
    SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
    FROM my_point_table group by gid, geom
    UNION ALL
    SELECT gid as pt_id, geom FROM my_point_table
) , tr as (
    SELECT pt_id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
    FROM buffer
    GROUP BY pt_id
)
select row_number() OVER (partition by pt_id), pt_id, geom from tr

First part is to mock your "my_point_table" table.

row_number() OVER (partition by pt_id)
is what generates a sequential number for each feature.


问:
How do I refresh branches (local/remote) in Visual Studio when using Git?

Update

Upgrading to Visual Studio 2019 16.8.X has a new git workflow. This also includes a fetch button.

Summary

I am learning how to use Git with Visual Studio.  I recently did a pull request where the feature branch was deleted after the merge.  The feature branch still shows up in my local and remote branches in Visual Studio.  I know how to right click and delete the branch, this is a workaround as others on the team may complete a pull request on a branch that I have without me knowing it.  If they delete the branch afterwards I would not know they did so.

Question

How do you refresh Visual Studio branches with what is on Git?

What I expect

I would expect a button, link, or right click feature that on click checks for differences, if any are found it asks, "This branch no longer exists, would you like to remove it from Visual Studio?".

Tech Specs

I am using Visual Studio 2015 Enterprise (still seems to be a symptom of VS 2019 for versions lower than 16.8)

Additional Example

This could be another question, but it fits so well here.  I just noticed that if I create a branch (say in one VM and look at the same repo with another), Visual Studio does not have a git fetch option to update the branch list.  The refresh button at the top does not seem to do anything.  As soon as I run git fetch in a bash, visual studio has the new branch.  I would expect the refresh to take care of this.

答:
From : "Refresh git remote branches in Visual Studio"

You can configure git to do this automatically on fetch/pull running with this command:

```<code>git config remote.origin.prune true –global
</code>```

Update:

Visual Studio 2017 version 15.7.3 and above you can do it using the UI :

In Team Explorer , click the Home then Setting:

Select Global settings

Change "Prune remote branches during fetch" to "True"

Body:
From : "Refresh git remote branches in Visual Studio"

You can configure git to do this automatically on fetch/pull running with this command:

git config remote.origin.prune true –global

Update:

Visual Studio 2017 version 15.7.3 and above you can do it using the UI :

In Team Explorer , click the Home then Setting:

Select Global settings

Change "Prune remote branches during fetch" to "True"