Hunter
April 11th, 2010, 05:00 PM
Web Development and Coding Support Thread
Post problems surrounding coding and design here. PHP, JS, AJAX, HTML, CSS, XML ect...
Thread would make a nice sticky in my opinion. Then people like me won't
need to make a load of threads for every problem that they have, but hey, that is my opinion and is usually wrong or ignore lmao. :haw:
--------------------------------------------------------------------
Problem/Error: split() function adding commer "," on the end of result
Fix highlighted in blue.
JavaScript:
function CSSchange(elm, class, apend, to) {
//If set to false the class variable will be taken from the final name
if (to == true) {
//If set to true then the class varialbe will be ADDED
if (apend == true) {
elm.className = elm.className+class;
} else {
//Selected element will have its class CHANGED
elm.className = class;
}
} else {
//Selected element will have the class variable deleted from final class name
elm.className = elm.className.split(class,1);
DEL>alert(elm.className.split(class));
}
}
HTML:
<div class="chat1" onmouseover="CSSchange(this, '_hover', true, true)" onmouseout="CSSchange(this, '_hover', true, false)">
Martyn Ball
</div>
Problem:
The alert displays "chat1,". The commer should not be there and I can't see where it is getting it from :maddowns:
Edit: Just tryed this: elm.className = elm.className.split(class,1); and it worked again :/ Weird. Keeping fix here anyway for future problems people may have.
What am I trying to do?
Well, basically make a rollover button, which will eventually do more when it is clicked, details are not needed.
This function could be used to make other rollover buttons, CSS has an attribute which can be added at the end of a style such as: button:hover / button:active. However because Internet Explorer is complete shit, this attribute usually ONLY works on links (<a></a>), although FireFox, Chrome and other browsers have no problem with this being used on other elements.
So this function could be used on elements such as dividers to swap their class so they will look different.
Post problems surrounding coding and design here. PHP, JS, AJAX, HTML, CSS, XML ect...
Thread would make a nice sticky in my opinion. Then people like me won't
need to make a load of threads for every problem that they have, but hey, that is my opinion and is usually wrong or ignore lmao. :haw:
--------------------------------------------------------------------
Problem/Error: split() function adding commer "," on the end of result
Fix highlighted in blue.
JavaScript:
function CSSchange(elm, class, apend, to) {
//If set to false the class variable will be taken from the final name
if (to == true) {
//If set to true then the class varialbe will be ADDED
if (apend == true) {
elm.className = elm.className+class;
} else {
//Selected element will have its class CHANGED
elm.className = class;
}
} else {
//Selected element will have the class variable deleted from final class name
elm.className = elm.className.split(class,1);
DEL>alert(elm.className.split(class));
}
}
HTML:
<div class="chat1" onmouseover="CSSchange(this, '_hover', true, true)" onmouseout="CSSchange(this, '_hover', true, false)">
Martyn Ball
</div>
Problem:
The alert displays "chat1,". The commer should not be there and I can't see where it is getting it from :maddowns:
Edit: Just tryed this: elm.className = elm.className.split(class,1); and it worked again :/ Weird. Keeping fix here anyway for future problems people may have.
What am I trying to do?
Well, basically make a rollover button, which will eventually do more when it is clicked, details are not needed.
This function could be used to make other rollover buttons, CSS has an attribute which can be added at the end of a style such as: button:hover / button:active. However because Internet Explorer is complete shit, this attribute usually ONLY works on links (<a></a>), although FireFox, Chrome and other browsers have no problem with this being used on other elements.
So this function could be used on elements such as dividers to swap their class so they will look different.