|
hasegawa posted:Alright, I'm trying to do a simple form validation for a drop box. I want it to give a "Hey choose something stupid" if the value is still "Select One" when the user clicks submit. With the current code, it allows the user to go to the next page regardless of what they choose in the dropdown box. I've tried several different javascript validators, but none of them seem to work with this. How would the browser know what document.term is? Make sure you are putting in LOTS of debug when learning / trying something new. If you added stuff to your code like so: code:
EDIT with solution: code:
Lumpy fucked around with this message at 22:52 on Apr 25, 2010 |
# ? Apr 25, 2010 22:41 |
|
|
# ? May 17, 2024 18:25 |
|
Doing some fun javascript with Google Maps v3. Currently I have it set up so that if you click a marker, it issues an AJAX request and loads info about that marker into a div next to the map. What I want to do is highlight the marker that is associated with the report being displayed. My first thought was to use a maps event listener to trap the click and swap the icon, like so: code:
Thoughts? I'm also using jQuery in other parts of the page, so I'm open to suggestions that use it.
|
# ? Apr 25, 2010 23:33 |
|
Lumpy posted:How would the browser know what document.term is? Ooh, I see! I wasn't sure how specific I had to be...if merely stating name=term would work or if I needed more precise. Thanks a million!
|
# ? Apr 26, 2010 00:33 |
|
hasegawa posted:Ooh, I see! I wasn't sure how specific I had to be...if merely stating name=term would work or if I needed more precise. Thanks a million! No problems. There was a push by MS back when IE6 was new to have any named element be acessable that way ( or something similar like document.all.someName i forget exact syntax ) but the standard is that you have to use document methods to get a reference to elements.
|
# ? Apr 26, 2010 01:05 |
|
A more clean approach would be to pass the form to the validation function:code:
|
# ? Apr 26, 2010 03:05 |
|
Blinkz0rz posted:Doing some fun javascript with Google Maps v3. Currently I have it set up so that if you click a marker, it issues an AJAX request and loads info about that marker into a div next to the map. What I want to do is highlight the marker that is associated with the report being displayed.
|
# ? Apr 26, 2010 03:46 |
|
Hey guys, completely new to Javascript. Using Flux for mac to create a tv based soundboard for shits and giggles. I've laid it all out, but have no idea how to even go about writing javascript, like, at all.. Help appreciated..
|
# ? May 3, 2010 19:02 |
|
roweski posted:Hey guys, completely new to Javascript. Using Flux for mac to create a tv based soundboard for shits and giggles. I've laid it all out, but have no idea how to even go about writing javascript, like, at all.. http://javascript.crockford.com/ Buy his book, and read this thread and look for all the other times people have asked this question and follow the suggestions there. Good luck, and have fun learning javascript. It's a neat little language.
|
# ? May 3, 2010 19:42 |
|
After searching for some sort of solution to rounded corners that worked cross-browser and could show image backgrounds behind elements with rounded corners, instead of just basing background color on the background color of the body and thus looking like poo poo, I came up with: 1) I still need to use images for this, 2) I have used GD Library in the past, I have to be able to generate these images automatically and have them inserted where needed 3) I could combine my need for this sort of functionality (gently caress you IE) with learning something. So, I am trying to make my own code to create transparent rounded corner .gif images with some sort of PHP(GD Library) and AJAX combo. I am still at a "planning"/"find out poo poo" stage, so here are my questions: Can you, with javascript, chop off the corners of an HTML element so that my fancy transparent, automatically generated .gif images will actually show the background of whatever element has round corners and not just the color of the square element? Is this even necessary? Is this a job for some other language instead, and in that case, any idea which? To actually put this into action when this is more done, how would I go about it best? My initial idea is simply to wrap a div around whichever element needs round corners and position the corner images absolutely in their relevant corners.
|
# ? May 4, 2010 21:52 |
|
I use http://www.roundedcornr.com/ which is a non-JS solution. You might want to take a look at the html/css they're generating, and how it works, before building your own.
|
# ? May 4, 2010 22:00 |
|
An alternative is to say "gently caress it" to IE and use the following CSS3 rule.code:
Obviously your don't want to do this if a large proportion of your traffic uses IE, or if rounded corners are absolutely necessary for your presentation. However, if you don't mind showing your IE visitors a slightly uglier site, using the above CSS is by far the easiest, most standards compliant way to do rounded borders. Also, Twitter does it. Edit: If you're looking for a javascript approach, take a look at the jquery rounded corners tutorial Haystack fucked around with this message at 04:40 on May 5, 2010 |
# ? May 5, 2010 04:27 |
|
I can't really say "gently caress it" to IE in this case. I figure that once I have this sort of functionality made once, I will never have to bother with this particular issue in IE again and can just wait it out until people get their asses in gear and update to some better browser. (Never) I've already tried JQuery libraries for rounded corners, though. Generally they insert the CSS you mention if the browser supports it, but in IE they generate corners it seems. Unfortunately, they base the corner background on the background color of the page itself. Setting the background color of the page to transparent simply makes the rounded corners in IE have a white background. Anyway, I could just get corner images from the services dotted around the net, but part of this is also a learning experience for me.
|
# ? May 5, 2010 09:12 |
|
this is as much an ajax/java/html question as it is a javascript question but whatever. I'm trying to figure out how to dynamically populate a dropdown list with all the .xml files on the server's main directory. Here's what I have: the html/javascript file: code:
code:
|
# ? May 6, 2010 02:08 |
|
First tell us where you're stuck. What is happening that you don't want to happen (or what's not happening that you want to happen)?
|
# ? May 6, 2010 02:35 |
|
I want my servlet to pass back the appropriate code that will be assigned to the javascript variable $("playList") so that it will load the dropdown list with all the xml filenames. I don't know what the proper code is for my servlet to send back nor how my HTML should be handling it.
|
# ? May 6, 2010 02:39 |
|
to be more specific i'm not sure what to do with the following sections: how the dropdown list should handle the returning code: code:
code:
|
# ? May 6, 2010 02:55 |
|
Hi all. Sorry for the I'm a bit confused with the question in one of my assignments. I'm not expecting anyone to do my homework for me, but a little nudge in the right direction would be really appreciated. This is the script: code:
Now, apart from deleting it and starting all over again, here's what I have to do. Check for semantic errors and then fix them. Simple huh? I'm a stupid newbie though and do not have a great idea of what the semantic errors could be. If someone could point me in the right direction, I'm sure I could finish it, but I need a little help to get going. Thanks Lee
|
# ? May 6, 2010 03:42 |
|
start at the beginning of the program and move an alert statement line by line to make sure everything is functioning how it should be. javascript is kind of a pain that way, but it will work. edit: I'm kind of wondering what your teacher means by 'semantic' errors as well
|
# ? May 6, 2010 03:43 |
|
Necc0 posted:edit: I'm kind of wondering what your teacher means by 'semantic' errors as well Errors where the syntax is correct, but the meaning isn't. Syntax error: code:
code:
|
# ? May 6, 2010 03:47 |
|
Necc0 posted:start at the beginning of the program and move an alert statement line by line to make sure everything is functioning how it should be. I'm sorry, but I'm not entirely sure how to do that. Is it something like code:
I think semantic errors are supposed to be a bit like syntax errors? ^^efb
|
# ? May 6, 2010 03:54 |
|
LeeJam posted:I'm sorry, but I'm not entirely sure how to do that. Is it something like kind of. go through the code line by line and ask yourself what you think the code is supposed to be doing. after each line, put an alert statement that prints out the variable values to make sure they are actually what they're supposed to be. this is a really monotonous way of checking the code but it will work.
|
# ? May 6, 2010 03:55 |
|
i've already found a couple. you don't even have to do my 'alert' method just go through it slowly, line by line, and ask yourself what you think the code *should* be doing versus what it actually is.
|
# ? May 6, 2010 03:58 |
|
I'll be honest I really need help with my problem this thing is due tomorrow and I'm only having a few issues I need resolved. I have no idea how to handle these few things though because I procrastinated and it's too late to ask my prof.
|
# ? May 6, 2010 03:59 |
|
Necc0 posted:I'll be honest I really need help with my problem this thing is due tomorrow and I'm only having a few issues I need resolved. I have no idea how to handle these few things though because I procrastinated and it's too late to ask my prof. It's way too complicated for me Thanks for the help though, I really appreciate it.
|
# ? May 6, 2010 04:03 |
|
Necc0 posted:this is as much an ajax/java/html question as it is a javascript question but whatever. I'm trying to figure out how to dynamically populate a dropdown list with all the .xml files on the server's main directory. JS snip: var url = "getPlayList?file="; Java snip: String fname = request.getParameter("file"); I don't know much about java servlets, but to me it looks like your not sending a filename through HTTP GET, so fname is evaluating to null. Either way, try using addons such as Firebug or HttpFox and watch the ajax traffic to see if the java is returning a bunch of <option> tags like it should.
|
# ? May 6, 2010 04:50 |
|
Necc0 posted:start at the beginning of the program and move an alert statement line by line to make sure everything is functioning how it should be. Even better, use Webkit's built in javascript debugger ( or whatever the best add-on one for Firefox is these days.. still Firebug? ) and save yourself having to put alerts all over the place! Also, the first "error" in that script is the formatting... Lumpy fucked around with this message at 05:17 on May 6, 2010 |
# ? May 6, 2010 05:12 |
|
Lumpy posted:Even better, use Webkit's built in javascript debugger ( or whatever the best add-on one for Firefox is these days.. still Firebug? ) and save yourself having to put alerts all over the place! Yeah, I know it's awful. I'm only working with what was given to me. It's supposed to check for negative numbers and get you to re-enter the numbers if you have done so.
|
# ? May 6, 2010 05:30 |
|
barbarianbob posted:JS snip: it's supposed to be null because all the xml files are located in the server's default directory. technically I could pass nothing at all and it would still work but I did that just for good design.
|
# ? May 6, 2010 14:29 |
|
LeeJam posted:Yeah, I know it's awful. I'm only working with what was given to me. Fun thing is, goofy braces can actually cause Bad Stuff in javascript. Take this example shamelessly stolen from Crockford's "java script: The Good Parts" talk... code:
|
# ? May 6, 2010 14:30 |
|
I'm writing the JS for a chat app I'm working on in my free time, and I need to have Ids that change according to user submitted data. This is usually something retarded that I would not do, but I don't see myself having much of a choice. code:
|
# ? May 8, 2010 05:51 |
|
MononcQc posted:I'm writing the JS for a chat app I'm working on in my free time, and I need to have Ids that change according to user submitted data. The "right" answer will depend on what you allow usernames to be. If usernames are email addresses, then you can do strict checking on that for instance. If it's arbitrary, you have a lot more work. Here's a good little guide I have bookmarked: http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
|
# ? May 8, 2010 15:36 |
|
Lumpy posted:The "right" answer will depend on what you allow usernames to be. If usernames are email addresses, then you can do strict checking on that for instance. If it's arbitrary, you have a lot more work. Yeah, right now (as this is still a prototype), I expected any character to be valid, but using it in ID puts a restriction on what I can use. I couldn't do any efficient escaping or encoding (like base64) without breaking the HTML. Putting assumptions about what is allowed will be necessary. From that point I figure it's more about filtering than escaping.
|
# ? May 8, 2010 15:41 |
|
I having a javasript/jquery problem with Firefox. These functions highlight and dehighlight all given classes on a page. It works in IE and Chrome, and it *used* to work in Firefox as well until now where it just doesn't. The function just isn't getting executed at all when I mouseover. Help is very much appreciated. code:
|
# ? May 12, 2010 18:16 |
|
Theler posted:I having a javasript/jquery problem with Firefox. Anyways, if you are going to use jQuery, you should really learn to not mix content with behavior. The events should be registered in your script, not via html attributes. peepsalot fucked around with this message at 18:38 on May 12, 2010 |
# ? May 12, 2010 18:35 |
|
peepsalot posted:Works for me (click the preview button to test), are you including the jquery library? Seriously. JQuery makes event handlers a million times easier. Case in point, here's how you'd do what Theler is trying to do. code:
|
# ? May 12, 2010 23:26 |
|
Thanks for the advice on using JQuery better as obvious I haven't really used it much. The problem was in fact though with the ASP.net test server that Visual Studio runs. It works everywhere but there.
Theler fucked around with this message at 11:42 on May 14, 2010 |
# ? May 13, 2010 15:14 |
|
I'm writing a little app that lets me make a list of all the ports on network/pdu/whatever equipment and I'm having a little trouble figuring out the recursion. Basically I want to take input and spit it out into arrays like these examples code:
Edit: Ok, this wasn't that hard I was just not thinking properly. Now that it's in an array I can print it out in the correct format and I have the correct number of entries. code:
code:
ElCondemn fucked around with this message at 01:55 on May 18, 2010 |
# ? May 18, 2010 00:18 |
|
php:<? <select id="a"> <option>1</option> <option>2</option> <option>3</option> </select> <script> obj = function() { this.change_now = function() { console.log('Where does /this/ point to?'); console.log(this); this.say_hooray(); // hj;alp } this.say_hooray = function() { alert('Hooray!'); } } an_object = new obj(); document.getElementById("a").onchange = an_object.change_now; </script>?> I know I could do an_object.say_hooray(), but in the real world that doesn't work since I don't know the variable name beforehand. Is there a way to grab a reference to the original instance of obj even if this points to something else? karms fucked around with this message at 14:54 on May 21, 2010 |
# ? May 21, 2010 14:48 |
|
document.getElementById("a").onchange = function() { return an_object.onchange(); };
|
# ? May 21, 2010 14:54 |
|
|
# ? May 17, 2024 18:25 |
|
Gah!
|
# ? May 21, 2010 15:04 |