dpv21589 2015-10-13 05:42
浏览 16

无法将HTML值插入另一个

I'm trying to have the value of an HTML element equal the value of another. Sounds simple enough but when I try various options, it doesn't work

Here's what I'm trying to do:

1]

  1. I tried a few things. First, I made a javascript function that when they info button is pressed, it simply sets the value of the newname textbox to the title and then I was going to use javascript to trim off the extension. As you can see on the page, it simply outputs {{modal_header}}. I believe this is because when the function is being called, the value hasn't been set yet and that's why it's outputting this. I couldn't find out where else to call the function in order for it to work.

  2. To get around that issue, I tried using PHP to retrieve the name. The only thing I could find related to the name was which in stuck in the value property of newname, but this output only the last file in the directory, no matter what file you selected.

I tried a bunch of different little things, but without any luck. You guys have any ideas?

Website: http://box.endurehosting.com/

HTML: http://pastebin.com/dZ5rKGUY

  • 写回答

1条回答 默认 最新

  • dqpciw9742 2015-10-13 05:51
    关注

    try this code

    $(function(){
        var title = $("#title").html();
        title = title.substr(0, title.indexOf('.'));
        $("#newname").val(title);
    })
    
    评论

报告相同问题?