小编Nit*_*ths的帖子

如何在点击图片按钮上传新文件

我有一项任务是从点击图片按钮上传新文件.我的代码是

    <label>File</lable>
    <input type="image" src="http://upload.wikimedia.org/wikipedia/commons/c/ca/Button-Lightblue.svg" width="30px"/>
Run Code Online (Sandbox Code Playgroud)

点击此按钮,我想上传一个新文件.我该怎么做?你可以从Demo查看我的代码

html javascript jquery css3

19
推荐指数
2
解决办法
7万
查看次数

通过rubyonrails中的脚手架设置对表的引用

我现在正在铁轨上做红宝石项目.我创建了一个名为product的实体,我想设置与其他实体命名类别的多对多关系.

script/generate scaffold product prd_name:string category:references 
Run Code Online (Sandbox Code Playgroud)

通过这个代码,只有一对一的映射是可能的.如何在没有硬编码的情况下设置多对多?

ruby ruby-on-rails

18
推荐指数
4
解决办法
3万
查看次数

验证失败时如何将文本框边框颜色设置为红色

当.net mvc 4中的验证失败时,我有一个任务为文本框设置红色边框.

BExtensionMethods.cs

    public static string GetTextBoxColor(this ModelStateDictionary ModelState)
    {
        string textBoxColor = string.Empty;
        int count = 1;
        var errorKeys = (from item in ModelState
                         where item.Value.Errors.Any()
                         select item.Key).ToList();
        foreach (var item in errorKeys)
        {
            textBoxColor += string.Format("{0}.{1}</br>", count, item);
            count++;
        }
        return textBoxColor;
    }
Run Code Online (Sandbox Code Playgroud)

这里json对象包含值.如何过滤它?

asp.net jquery asp.net-mvc-3-areas asp.net-mvc-4

10
推荐指数
3
解决办法
7万
查看次数

在轨道上的ruby中的SQL Like运算符

我有一个任务是选择搜索学生那些名字以param值和所选值的城市开头.我怎么能在轨道上设置ruby?我确实喜欢这个,但这不是控制器

 def list

    studentcount=Student.count()
    puts studentcount
    @studentname = Student.where("name name1 AND city = :cityId1",
    {:name1 => params[:name], :cityId1 => params[:cityId]})

    puts 'studentname'
    puts @studentname.inspect
    @students = Student.limit(params[:jtPageSize]).offset(params[:jtStartIndex]).order(params[:jtSorting])

    @jtable = {'Result' => 'OK','Records' => @students.map(&:attributes), :TotalRecordCount => studentcount}

    respond_to do |format|
      format.html # index.html.erb
      format.json { render :json => @jtable}
    end
  end
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails-3.2

9
推荐指数
2
解决办法
2万
查看次数

如何增加div id值?

我有一个任务将菜单设置为选中.为此,我使用动态ID.所以我想根据选择增加它

我的代码是

<div class="menuHeader ui-corner-top" id="menu"+ i>
    <span><a href="#" onclick="Home()">Home</a></span>
</div>
<div class="menuHeader ui-corner-top" id="menu"+ i>
    <span><a href="#" onclick="NewTransaction()">New Transaction</a></span>
</div>
<div class="menuHeader ui-corner-top" id="menu"+ i>
    <span><a href="#" onclick="Portfolio()">Portfolio</a></span>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript是

$(document).ready(function () {
             alert(document.URL);
             var list = $("#menu");
             for (var i = 1; i <= list.length; i++) {
                 list[i].innerHTML = i;
             }
             var str = document.URL.toLowerCase().indexOf("portfolio/index");
             alert(str);
             if (str >= 0) {
                 $('#menu').addClass("menuHeaderActive");
             }
         });
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

html javascript jquery

7
推荐指数
1
解决办法
3万
查看次数

jquery日期选择器中的语言翻译

如何在jquery日期选择器中同时包含语言翻译和changeMonth以及changeYear选项.为此,我使用下面的代码进行语言翻译

$(this).datepicker($.datepicker.regional['fr']);
Run Code Online (Sandbox Code Playgroud)

对于ChangeYear

$( this ).datepicker({
      changeMonth: true,
      changeYear: true
    });
Run Code Online (Sandbox Code Playgroud)

我想在一个datepicker框中运行这两个.请帮助

html javascript jquery

7
推荐指数
1
解决办法
8311
查看次数

占位符不起作用

占位符在IE-9中不起作用,因此我使用以下代码作为占位符.

 jQuery(function () {
     debugger;
     jQuery.support.placeholder = false;
     test = document.createElement('input');
     if ('placeholder' in test) jQuery.support.placeholder = true;
 });
 // This adds placeholder support to browsers that wouldn't otherwise support it.
 $(function () {

     if (!$.support.placeholder) {
         var active = document.activeElement;
         $(':text').focus(function () {
             if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                 $(this).val('').removeClass('hasPlaceholder');
             }
         }).blur(function () {
             if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                 $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
             }
         });
         $(':text').blur();
         $(active).focus();
         $('form:eq(0)').submit(function () {
             $(':text.hasPlaceholder').val(''); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

7
推荐指数
1
解决办法
270
查看次数

如何在一个表单中编辑多个模型?

我从训练师那里得到了一个任务.我想在一个表单中编辑两个模型.例如,我们有两个实体学生和地址.在新学生部分,我想添加学生的详细信息和地址.我如何通过铁轨上的红宝石搭建脚手架来实现这一目标?

ruby ruby-on-rails scaffolding

6
推荐指数
1
解决办法
1700
查看次数

如何仅为字母字母启用onpaste

我有一个任务来禁用文本框粘贴.只有字母字符必须允许粘贴.我的代码是

<b>Name</b>
<input type="text" id="name" onpaste="return false"/>
Run Code Online (Sandbox Code Playgroud)

通过给onpaste ="return false",不会粘贴任何值.我怎么解决这个问题?

html javascript jquery html5

6
推荐指数
1
解决办法
1962
查看次数

如何在选择时为菜单应用CSS?

我有一项任务是在加载页面时突出显示所选的菜单.为此,我有以下代码:

$('.menuHeader').each(function () {
    $(this).attr('id', 'menu' + ($(this).index() + 1));
    $(this).val($(this).index() + 1);

    // Set the dynamic ids for links
    $(this).find('a').attr('id', 'link' + ($(this).index() + 1));
    //alert('New ID  :  ' + $(this).find('a').attr('id'));
});

$('.menuHeader a').click(function () {
    alert("a");
    $('.menuHeader a').removeClass('menuHeaderActive');
    $(this).parent().parent(".menuHeader").addClass('menuHeaderActive');
});
Run Code Online (Sandbox Code Playgroud)

但是当我选择第二个菜单时,它会刷新并错过选择.

HTML:

<div class="menuBar">
    <div class="menuHeader ui-corner-top menuHeaderActive">
        <span><a href="#" onclick="Home()">Home</a></span>
    </div>
    <div class="menuHeader ui-corner-top">
        <span><a href="#" onclick="NewTransaction()">New Transaction</a></span>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

 function Home() {
            window.location.href = "../../home/welcome";
        }
        function NewTransaction() {
            window.location.href = "../../EnergyCatagory/index";
        }
Run Code Online (Sandbox Code Playgroud)

html javascript cookies jquery

6
推荐指数
1
解决办法
352
查看次数