允许用户更改背景? &安培;插入数据库

时间:2014-01-18 09:50:45

标签: javascript html mysql css background

基本上我想做的是允许我的用户更改他们的背景,然后数据进入名为theme的users表下的数据库。

例如,如果有一个名为tiger的主题,他们从下拉框中选择并按下保存主题将老虎插入数据库,老虎主题是他们的新背景?

我正在寻找这个cms,但我无法解决该怎么做。

这是它的HTML。     

                    <div class="legend" style="padding-top: 9px;">Thema</div>

                    <select class="inputSettingsTheme settingsInput">
                        <option value="tanzania" {if $user.fetch.theme == 'tanzania'}selected{/if}>Tanzania</option>
                        <option value="steampunk" {if $user.fetch.theme == 'steampunk'}selected{/if}>Steampunk</option>
                        <option value="piraten" {if $user.fetch.theme == 'piraten'}selected{/if}>Pirates</option>
                        <option value="pasen" {if $user.fetch.theme == 'pasen'}selected{/if}>Easter</option>
                        <option value="palooza" {if $user.fetch.theme == 'palooza'}selected{/if}>Palooza</option>
                        <option value="olympic" {if $user.fetch.theme == 'olympic'}selected{/if}>Olympic</option>
                        <option value="normal" {if $user.fetch.theme == 'normal'}selected{/if}>Normal</option>
                        <option value="newyear_2013" {if $user.fetch.theme == 'newyear_2013'}selected{/if}>New year 2013</option>
                        <option value="mystics" {if $user.fetch.theme == 'mystics'}selected{/if}>Mystics</option>
                        <option value="mute" {if $user.fetch.theme == 'mute'}selected{/if}>Mute</option>
                        <option value="love" {if $user.fetch.theme == 'love'}selected{/if}>Love</option>
                        <option value="kenia" {if $user.fetch.theme == 'kenia'}selected{/if}>Kenia</option>
                        <option value="hstars" {if $user.fetch.theme == 'hstars'}selected{/if}>Habbo Stars</option>
                        <option value="halloween" {if $user.fetch.theme == 'halloween'}selected{/if}>Halloween</option>
                        <option value="football" {if $user.fetch.theme == 'football'}selected{/if}>Football</option>
                        <option value="egypte" {if $user.fetch.theme == 'eqypte'}selected{/if}>Egypte</option>
                    </select>

                </div>

这是在同一页面的括号内。

 <script>
    $(document).ready(function(){           

        $('.onclickSaveSettings').click(function(){
            $('.onclickSaveSettings').toggleClass("loader");                

            var theme = $('.inputSettingsTheme').val();

                    if(theme != '{$user.fetch.theme}') {
                        $('html').css('background-image', 'url(../assets/image/general/backdrop/'+theme+'/reception_backdrop_stretch.png)');
                        $('.backDrop .horizon').css('background-image', 'url(../assets/image/general/backdrop/'+theme+'/reception_backdrop_horizon.png)');
                        $('.backDrop .leftBackdrop').css('background-image', 'url(../assets/image/general/backdrop/'+theme+'/reception_backdrop_left.png)');
                        $('.backDrop .rightBackdrop').css('background-image', 'url(../assets/image/general/backdrop/'+theme+'/reception_backdrop_right.png)');
                    }
                });
            }
        });

    </script>

关于如何使这个工作的任何想法?

谢谢, 约什

1 个答案:

答案 0 :(得分:0)

使用change()事件,它会更好。

http://api.jquery.com/change/

示例:

$( ".settingsInput" ).change(function() {
//Set theme
//Save entry to DB
});