• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=jaooe;40499254]Didn't think of that, D'oh. Cheers! Google "forms javascript" and you'll find everything you need.[/QUOTE] Java != javascript
[QUOTE=P1raten;40500016]Java != javascript[/QUOTE] I has been let to believe it <>
I've been struggling with following piece of Javascript. It works as it should but for some reason it only affects the last [B]document.getElementsByClassName("post_frame")[/B] the particular page has. Any ideas what's wrong? [CODE] var varFek = document.getElementsByClassName("post_frame"); var region = window.location.host; var regionSlice = region.slice(0, -20); var i; var name; var userIcon; var imgsrc; var avatar; for (i = 0; i < varFek.length; i++) { name = varFek[i].getElementsByTagName("big")[0].innerHTML; userIcon = varFek[i].getElementsByClassName("user_icon")[0]; imgsrc = varFek[i].getElementsByClassName("user_icon")[0].src; avatar = "http://fileserveraddress.example/avatar/" + regionSlice + "/" + encodeURIComponent(name); /// varFek[i].getElementsByClassName("photo")[0].setAttribute("style", "background: 0 !important"); varFek[i].getElementsByClassName("right_orb")[0].setAttribute("style", "display: none"); varFek[i].getElementsByClassName("left_orb")[0].setAttribute("style", "display: none"); userIcon.setAttribute("style", "width:80px !important;height:80px !important;position:relative; TOP:0px;border-style: double;border-color: grey; border-width: 4px;border-radius:3px;"); /// function changer() { if (varFek[i].getElementsByTagName("big")[0].getElementsByTagName("font")[0] === undefined) { function checkImage(srcs) { var img = new Image(); img.onload = function () { userIcon.src = srcs; }; img.onerror = function () {/* nothing */ }; img.src = srcs; } } checkImage(avatar); } changer(); }[/CODE] [editline]3rd May 2013[/editline] I mean the[B] function changer()[/B] only affects the last index of [B]document.getElementsByClassName("post_frame")[/B]
[QUOTE=Worre;40513856]I've been struggling with following piece of Javascript. It works as it should but for some reason it only affects the last [B]document.getElementsByClassName("post_frame")[/B] the particular page has. Any ideas what's wrong? [CODE] var varFek = document.getElementsByClassName("post_frame"); var region = window.location.host; var regionSlice = region.slice(0, -20); var i; var name; var userIcon; var imgsrc; var avatar; for (i = 0; i < varFek.length; i++) { name = varFek[i].getElementsByTagName("big")[0].innerHTML; userIcon = varFek[i].getElementsByClassName("user_icon")[0]; imgsrc = varFek[i].getElementsByClassName("user_icon")[0].src; avatar = "http://fileserveraddress.example/avatar/" + regionSlice + "/" + encodeURIComponent(name); /// varFek[i].getElementsByClassName("photo")[0].setAttribute("style", "background: 0 !important"); varFek[i].getElementsByClassName("right_orb")[0].setAttribute("style", "display: none"); varFek[i].getElementsByClassName("left_orb")[0].setAttribute("style", "display: none"); userIcon.setAttribute("style", "width:80px !important;height:80px !important;position:relative; TOP:0px;border-style: double;border-color: grey; border-width: 4px;border-radius:3px;"); /// function changer() { if (varFek[i].getElementsByTagName("big")[0].getElementsByTagName("font")[0] === undefined) { function checkImage(srcs) { var img = new Image(); img.onload = function () { userIcon.src = srcs; }; img.onerror = function () {/* nothing */ }; img.src = srcs; } } checkImage(avatar); } changer(); }[/CODE] [editline]3rd May 2013[/editline] I mean the[B] function changer()[/B] only affects the last index of [B]document.getElementsByClassName("post_frame")[/B][/QUOTE] You're redefining the function "changer" each time the loop iterates and then calling it. Define the function outside the for loop. It's like you're actually asking for performance loss. [editline]3rd May 2013[/editline] [QUOTE=jaooe;40486890]Still doesn't work :/[/QUOTE] Styling "a" elements with css isn't troublesome at all as long as you use classes or properly define each style as a subelement. [code]#nav > a:hover { /* stoeff */ }[/code] I'd say try to do it without the ul and li elements and see what happens.
[QUOTE=P1raten;40513907]You're redefining the function "changer" each time the loop iterates and then calling it. Define the function outside the for loop. It's like you're actually asking for performance loss.[/QUOTE] Did that and it still happens.
[QUOTE=Worre;40513953]Did that and it still happens.[/QUOTE] Use jquery instead? A whole lot easier to iterate through the elements. [code] $('.post_frame').each(function() { /* Loop code here. */ }); [/code] EDIT: Also there's no reason for you to use that function what so ever, just place the code by itself in the loop And I just noticed that you defined a function within a function. [B]STOP THIS FUNCEPTION. >:([/B]
[QUOTE=P1raten;40513970]Use jquery instead? A whole lot easier to iterate through the elements. [code] $('.post_frame').each(function() { /* Loop code here. */ }); [/code][/QUOTE] I'm actually trying to convert my jQuery to plain Javascript because my project requires it (Opera add-on doesn't work if it's written in jQuery.)
[QUOTE=Worre;40513991]I'm actually trying to convert my jQuery to plain Javascript because my project requires it (Opera add-on doesn't work if it's written in jQuery.)[/QUOTE] Post the HTML code as well on jsfiddle. It's easier to see what's wrong if we can see the big picture.
[QUOTE=P1raten;40514001]Post the HTML code as well on jsfiddle. It's easier to see what's wrong if we can see the big picture.[/QUOTE] Here: [url]http://jsfiddle.net/5WD6b/1/[/url] [editline]3rd May 2013[/editline] Weirdly, it started to put the image Worre should be getting for Xebitu. This kind of thing also happens in the actual site.
File upload in rails ?
[QUOTE=P1raten;40517392]File upload in rails ?[/QUOTE] [url]https://github.com/thoughtbot/paperclip[/url]
-snip-
Ok, I've fixed my problem now, it was cause by defining functions in for loop.
[QUOTE=Worre;40526036]Ok, I've fixed my problem now, it was cause by defining functions in for loop.[/QUOTE] Like I told you, then?
[QUOTE=P1raten;40526182]Like I told you, then?[/QUOTE] Yeah, thanks.
[QUOTE=Soleeedus;40473289]hmm, getting some weird issues with my site, specifically with margins on my bottom bit. for example, the [URL="http://soleedus.me"]main page[/URL], which looks fine however, on my [URL="http://soleedus.me/404.htm"]404 page[/URL], the bottom bit completely breaks with the addition of another tile, as seen here: [t]http://puu.sh/2JR21.png[/t] I've tried changing the margins in my [URL="http://pastebin.com/mCPfz0tj"]CSS[/URL] to no avail. probably a dumb little mistake I'm making, but i'm not entirely sure. anyone know what's fucked?[/QUOTE] Dude, what, I just compared the source to your site's main page to mine. Mine: [img]http://i.imgur.com/ONUso69.png[/img] Yours: [img]http://i.imgur.com/8wPaL5o.png[/img] Why would you even.
[QUOTE=AndrewPH;40532674]Dude, what, I just compared the source to your site's main page to mine. Mine: [img]http://i.imgur.com/ONUso69.png[/img] Yours: [img]http://i.imgur.com/8wPaL5o.png[/img] Why would you even.[/QUOTE] Well that would explain him not understanding the CSS and why there is an image there instead of text. Also he has set his favicon to a SS symbol.
[QUOTE=AndrewPH;40532674]Dude, what, I just compared the source to your site's main page to mine. Mine: [img]http://i.imgur.com/ONUso69.png[/img] Yours: [img]http://i.imgur.com/8wPaL5o.png[/img] Why would you even.[/QUOTE] Now I ask you. Why are you calling stuff bottom[B]bit[/B]
[QUOTE=Killervalon;40534425]Now I ask you. Why are you calling stuff bottom[B]bit[/B][/QUOTE] Well on my personal site I'm calling stuff "hi_its_me_mario" and related stuff so it's no that weird.
[QUOTE=asantos3;40535079]Well on my personal site I'm calling stuff "hi_its_me_mario" and related stuff so it's no that weird.[/QUOTE] Isn't that a bit confusing when you have to fix it later on?
I'm making a website for a assignment and I [U]have[/U] to use Dreamweaver for it, I was just wonder what the general consensus is about wysiwyg editors (I've heard it not recommended). I've pretty much got no html/css experience, Is it alright for someone with zero experience like me to use them, or should I look at some coding?
Generally, Dreamweaver's wysiwyg is bad. And I recommend learning the actual language instead of relying on wysiwyg editors.
[QUOTE=Killervalon;40535345]Isn't that a bit confusing when you have to fix it later on?[/QUOTE] Nah, it's a quite small site so not really a problem.
[QUOTE=Worre;40535493]Generally, Dreamweaver's wysiwyg is bad. And I recommend learning the actual language instead of relying on wysiwyg editors.[/QUOTE] Ok then, I've already been tinkering around with the script side of things, only using dreamweaver if I don't know how something works (plus it counts as "using" dreamweaver so I don't get picked up on anything). So far I made this little shitty webpage, I feel so proud: [url]https://dl.dropboxusercontent.com/u/64863030/site/SOLIDUS.html[/url]
Advice to anyone that visits that link; don't let it play
[QUOTE=Killervalon;40534425]Now I ask you. Why are you calling stuff bottom[B]bit[/B][/QUOTE] No reason. I made the design in about a day, so there's a lot of stuff that could be improved, like fixing that problem with small resolutions.
[QUOTE=Whomobile;40535780]Ok then, I've already been tinkering around with the script side of things, only using dreamweaver if I don't know how something works (plus it counts as "using" dreamweaver so I don't get picked up on anything). So far I made this little shitty webpage, I feel so proud: [url]https://dl.dropboxusercontent.com/u/64863030/site/SOLIDUS.html[/url][/QUOTE] You "made" a background - which you probably took without anyones concent - and put a video on it? How much time did you spend on it? 30 seconds?
[QUOTE=P1raten;40537546]You "made" a background - which you probably took without anyones concent - and put a video on it? How much time did you spend on it? 30 seconds?[/QUOTE] Don't be that guy, just remember when you started learning, every little things matters when you start learning.
Ok, so I tried putting some sort of write X on html site, see it written in a php site, but it doesn't work. I saw few tutorials on how to setup this but whenever I try to see if it works, the site it redirects shows the code and that's it. Here's the link in case someone could tell me what am I doing wrong [url]https://dl.dropboxusercontent.com/s/kxlck3sehchbluk/testphp.html[/url]
[QUOTE=B-Rabbit;40539988]Ok, so I tried putting some sort of write X on html site, see it written in a php site, but it doesn't work. I saw few tutorials on how to setup this but whenever I try to see if it works, the site it redirects shows the code and that's it. Here's the link in case someone could tell me what am I doing wrong [url]https://dl.dropboxusercontent.com/s/kxlck3sehchbluk/testphp.html[/url][/QUOTE] You can't use dropbox as a PHP host. Don't use the <center> or <font> tags, use CSS. Don't just echo things from GET or POST, use strip_tags() or htmlentities().
Sorry, you need to Log In to post a reply to this thread.