在一个页面中创建参数显示在另一个页面中

时间:2014-12-29 18:41:32

标签: javascript jquery html

我有两页如屏幕截图所示:
img1
img2
HTML

<div class="sm_img">

    <img src="img/angelic - Copy - Copy - Copy (2).png" id="angelic" /> <span>Angelic</span>

</div>

<div class="sm_img">

    <img src="img/angry - Copy - Copy - Copy.png" id="angry" /> <span>Angry</span>

</div>

<div class="sm_img">

    <img src="img/anxious - Copy - Copy - Copy.png" id="anxious" /> <span>Anxious</span>

</div>

<div class="sm_img">

    <img src="img/assertive - Copy - Copy.png" id="asserive" /> <span>Assertive</span>

</div>

<div class="sm_img">

    <img src="img/bored - Copy - Copy.png" id="bored" /> <span>Bored</span>

</div>

<div class="sm_img">

    <img src="img/confident - Copy - Copy.png" id="confident" /> <span>Confident</span>

</div>

<div class="sm_img">

    <img src="img/cranky - Copy - Copy.png" id="cranky" /> <span>Cranky</span>

</div>

<div class="sm_img">

    <img src="img/depressed - Copy - Copy.png" id="depressed" /> <span>Depressed</span>

</div>

<div class="sm_img">

    <img src="img/dissapointed - Copy - Copy.png" id="disappointed" /> <span>Dissapointed</span>

</div>

<div class="sm_img">

    <img src="img/distrustful - Copy - Copy.png" id="distrustful" /> <span>Distrustful</span>

</div>

<div class="sm_img">

    <img src="img/embarrassed - Copy.png" id="embarassed" /> <span>Embarrassed</span>

</div>

<div class="sm_img">

    <img src="img/emotional - Copy.png" id="emotional" /> <span>Emotional</span>

</div>

<div class="sm_img">

    <img src="img/evil - Copy.png" id="evil" /> <span>Evil</span>

</div>

<div class="sm_img">

    <img src="img/excited - Copy.png" id="excited" /> <span>Excited</span>

</div>

<div class="sm_img">

    <img src="img/exhusted.png" id="exhausted" /> <span>Exhusted</span>

</div>

<div class="sm_img">

    <img src="img/flirtatious.png" id="flirt" /> <span>flirtatious</span>

</div>

<div class="sm_img">

    <img src="img/forgetful.png" id="forget" /> <span>forgetful</span>

</div>

'Javascript`

<script type="text/javascript">
    function saveSmileys() {
        /* var a = document.getElementById("angelic");
        var b = document.getElementById("angry");
        var c = document.getElementById("anxious");
        var d = document.getElementById("assertive");
        var e = document.getElementById("bored");
        var f = document.getElementById("confident");
        var g = document.getElementById("cranky");
        var h = document.getElementById("depressed");
        var i = document.getElementById("disappointed");
        var j = document.getElementById("distrustful");
        var k = document.getElementById("emotional");
        var l = document.getElementById("evil");
        var m = document.getElementById("excited");
        var n = document.getElementById("exhausted");
        var o = document.getElementById("flirt");
        var p = document.getElementById("forget");
 */
        /* if (a & b & c & d & e & f & g & h & i & j & k & l & m & n & o
                & p == true) { */

/*          var ang = parseInt(a);
            var an = parseInt(b);
            var anx = parseInt(c);
            var asse = parseInt(d);
            var bo = parseInt(e);
            var co = parseInt(f);
            var cr = parseInt(g);
            var de = parseInt(h);
            var dis = parseInt(i);
            var distr = parseInt(j);
            var em = parseInt(k);
            var ev = parseInt(l);
            var ex = parseInt(m);
            var exh = parseInt(n);
            var fl = parseInt(o);
            var fo = parseInt(p); */

            $(function() {
                $("#savesmiley").bind(
                        "click",
                        function() {
                            var url = "notes.html?Angelic="
                                    + encodeURIComponent($("#angelic").val())
                                    + "&Angry="
                                    + encodeURIComponent($("#angry").val())
                                    + "&Anxious="
                                    + encodeURIComponent($("#anxious").val())
                                    + "&Assertive="
                                    + encodeURIComponent($("#assertive").val())
                                    + "&Bored="
                                    + encodeURIComponent($("#bored").val())
                                    + "&Confident="
                                    + encodeURIComponent($("#confident").val())
                                    + "&Cranky="
                                    + encodeURIComponent($("#cranky").val())
                                    + "&Depressed="
                                    + encodeURIComponent($("#depressed").val())
                                    + "&Disappointed="
                                    + encodeURIComponent($("#disappointed").val())
                                    + "&Distrustful="
                                    + encodeURIComponent($("#distrustful").val())
                                    + "&Embarassed="
                                    + encodeURIComponent($("#embarassed").val())
                                    + "&Emotional="
                                    + encodeURIComponent($("#emotional").val())
                                    + "&Evil="
                                    + encodeURIComponent($("#evil").val())
                                    + "&Excited="
                                    + encodeURIComponent($("#excited").val())
                                    + "&Exhausted="
                                    + encodeURIComponent($("#exhausted").val())
                                    + "&Flirtatious="
                                    + encodeURIComponent($("#flirt").val())
                                    + "&Forgetful="
                                    + encodeURIComponent($("#forget").val());
                            window.location.href = url;
                        });
            });


        var QueryString = function() {

            var query_string = {};
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i = vars.length; i++) {

                var pair = vars[i].split("=");
                if (typeof query_string[pair[0]] === "undefined") {

                    query_string[pair[0]] = pair[1];

                } else if (typeof query_string[pair[0]] === "string") {

                    var arr = [ query_string[pair[0]], pair[1] ];
                    query_string[pair[0]] = arr;

                } else {

                    query_string[pair[0]].push(pair[1]);

                }

            }

            console.log(query_string[pair[i]]);

        }
        alert("Moods have been saved");
    }
</script>

HTML ( Notes page )

<div style="position: absolute; top: 16px; left: 38px;">Date:</div>

        <div style="position: absolute; right: 16px; top: 12px;">
            <input type=date id="dte">
        </div>

        <div style="position: absolute; top: 55px; left: 36px;">Flow:</div>

        <div class="starbox ghosting autoupdate"
            style="position: absolute; right: 16px; top: 46px;" id="star"></div>

        <div style="position: absolute; top: 91px; left: 10px;">Period
            Ends Today!</div>

        <input type="checkbox" id="checkone"
            style="position: absolute; right: 40px; top: 90px;">

        <div style="position: absolute; top: 131px; left: 33px;">Note:</div>

        <div style="position: absolute; right: 15px; top: 126px;">
            <textarea id="note" id="nte"></textarea>
        </div>

        <div style="position: absolute; top: 174px; left: 20px;">Medicine:</div>
        <div style="position: absolute; right: 10px; top: 173px;">
            <input type="text" id="med">
        </div>

        <div style="position: absolute; top: 211px; left: 20px;">Symptoms:</div>
        <div>
            <a href="symptoms.html"><img src="./img/arrow.jpg"
                style="position: absolute; height: 40px; top: 197px; right: 10px;"></a>
        </div>

        <div style="position: absolute; top: 247px; left: 30px;">Moods</div>
        <div>
            <a href="smiley.html"><img src="./img/arrow.jpg"
                style="position: absolute; height: 40px; right: 10px; top: 234px;"></a>
        </div>

        <div style="position: absolute; top: 282px; left: 18px;">Intercourse</div>

        <input type="checkbox" id="checktwo"
            style="position: absolute; top: 283px; right: 40px;">

        <div style="position: absolute; bottom: 64px; left: 26px;">Weight:</div>
        <div style="position: absolute; top: 318px; left: 155px;">
            <input type="text" id="wgt"
                style="right: -138px; position: absolute;"
                placeholder="Wieght in Kg or lb">
        </div>
        <!-- <div style="position: absolute; right: 30px; bottom: 94px;">
            <select>
                <option value="kg">Kg</option>
                <option value="lb">lb</option>
            </select>
        </div> -->

        <div style="position: absolute; bottom: 35px; left: 11px;">Temparature:</div>
        <div style="position: absolute; bottom: 54px; left: 155px;">
            <input type="text" id="wgt1"
                style="right: -138px; position: absolute;"
                placeholder="Temparature in &#x2103; or &#x2109;">
        </div>
        <!-- <div style="position: absolute; right: 30px; bottom: 53px;">
            <select>
                <option value="centigrade">&#x2103;</option>
                <option value="faranheit">&#x2109;</option>
            </select>
        </div> -->

我的问题是:如果选择Assertive心情并保存,那么它(自信,即所选心情的名称)应显示在备注页面的Moods旁边。我该怎么做?以上javascript无效。

0 个答案:

没有答案