Anyway, given the techno-genius often on display here, I figured this would be worth asking. I've G00gled for over a day now trying to find out a way to validate (via JS, obv.) whether these cockfarming checkbox fields in my ASP form are checked off or not.
I call a validateForm function on form submittal (referring to the form as "this"), and have, at last glance, attempted this sort of mojo:
for (i = 0; i < theForm.solArea.length; i++) if (theForm.checkbox[i].checked){ count = true; }return count;
When I leave the boxes unchecked, nothing happens. I tried inserting an ALERT statement in the for loop to see if the damn IF statement's accessed when a box is checked, but nothing displayed. What the eff?
Any & all assistance is appreciated.
― David R. (popshots75`), Wednesday, 9 March 2005 14:44 (twenty years ago)
― mark grout (mark grout), Wednesday, 9 March 2005 14:47 (twenty years ago)
― ken c (ken c), Wednesday, 9 March 2005 14:51 (twenty years ago)
― David R. (popshots75`), Wednesday, 9 March 2005 14:51 (twenty years ago)
(See, solArea is the name of the stupid CHECKBOX! Guess who cut & pasted from G00gle w/out double-checking!)
― David R. (popshots75`), Wednesday, 9 March 2005 14:52 (twenty years ago)
― David R. (popshots75`), Wednesday, 9 March 2005 14:54 (twenty years ago)
― ken c (ken c), Wednesday, 9 March 2005 14:54 (twenty years ago)
― The Ghost of Dan Perry (Dan Perry), Wednesday, 9 March 2005 14:56 (twenty years ago)
[xpost w/ luv]
― David R. (popshots75`), Wednesday, 9 March 2005 14:58 (twenty years ago)
― David R. (popshots75`), Wednesday, 9 March 2005 18:09 (twenty years ago)
I'm trying to create a "Bookmark this site" link on a page. I found some code to do it, but in Mozilla browsers, it creates the bookmark in a pane, instead of in the main browser window.
Here's the code:
function bookmarksite(title, url){ if (document.all) window.external.AddFavorite(url, title); else if (window.sidebar) window.sidebar.addPanel(title, url, "") }
That last line looks like the culprit, but I don't know how to change it.
Here's an example of it in action (and the place from which I stole the code)http://www.dynamicdrive.com/dynamicindex9/addbook.htm
..Any ideas/alt-solutions?
― D.I.Y. U.N.K.L.E. (dave225.3), Wednesday, 11 January 2006 16:05 (nineteen years ago)
http://www.actionscript.org/forums/archive/index.php3/t-52789.html
but i'm with the bloke who says it's pointless (and dangerous)
― koogs (koogs), Wednesday, 11 January 2006 16:17 (nineteen years ago)
― D.I.Y. U.N.K.L.E. (dave225.3), Wednesday, 11 January 2006 16:26 (nineteen years ago)
― Forest Pines (ForestPines), Wednesday, 11 January 2006 16:38 (nineteen years ago)
(marketing.)
― D.I.Y. U.N.K.L.E. (dave225.3), Wednesday, 11 January 2006 17:37 (nineteen years ago)
OK I'm a complete noob at Javascript, I've never used it before this week, so forgive my stupidity...
Say I have an array like this: x,z,a,d,h,s I want to be able to remove a specific one of these, I understand I can do this with array.splice([index of item to remove], 1), however this assumes you know what the index of the item you want to remove is. W3Schools says there is an array.index property, but does not say anything about what it does.
Basically I want to do something like array.splice(array.index('d'), 1) is this possible or do I have to do a FOR loop to get the index by comparing each item to the value I want to remove??
― Colonel Poo, Tuesday, 15 January 2008 16:52 (seventeen years ago)
http://www.devguru.com/technologies/ecmascript/QuickRef/array.html
"index Property The read-only index property for an array created by a regular expression match and containing the zero-based index of that match."
try it and see would be my suggestion.
javascript 1.6 adds indexOf which sounds more likely.
― koogs, Tuesday, 15 January 2008 17:06 (seventeen years ago)
I don't really ever use Javascript, but I'm fairly certain there's no way outside of the loop (xpost: good to see indexOf is finally making its way in.) This should do the trick:
function findInArray(array, element){ for (i=0; i<array.length; i++){ if (array[ i ] == element){ return i; } } return -1; }function removeElementFromArray(array, element){ index = findInArray(array, element); if (index >= 0){ array.splice(index,1); } }
function removeElementFromArray(array, element){ index = findInArray(array, element); if (index >= 0){ array.splice(index,1); } }
monkeys = [ "cranky", "happy", "Kingsley", "spoon" ]; document.write (monkeys); removeElementFromArray(monkeys, "Kingsley"); document.write (" !! " + monkeys);
― Øystein, Tuesday, 15 January 2008 17:29 (seventeen years ago)
Thanks both, the example you've given Oystein is pretty much the way I was going to go about it. I guess I'll try the index/indexOf anyway and see if it works although it'll take a bit more coding to know what the result is!
― Colonel Poo, Tuesday, 15 January 2008 17:39 (seventeen years ago)
Woo! IndexOf does work! Hurrah. Thanks!
― Colonel Poo, Tuesday, 15 January 2008 17:55 (seventeen years ago)
what if the element happens twice?
― ken c, Wednesday, 16 January 2008 02:05 (seventeen years ago)
You get the index of the first instance.
― libcrypt, Wednesday, 16 January 2008 03:32 (seventeen years ago)
Note that if you want to support IE6, you can't use indexOf(), since IE6 only supports Javascript 1.3.
― libcrypt, Wednesday, 16 January 2008 03:37 (seventeen years ago)
I have a similar question to the first one. basically I have a form with about 50 checkboxes on it and a text area box. I need to make srue at least one of the checkboxes is selected (doesn't matter which one, we just don't want empty forms) or the text area is typed it; basically, one input needs something. why is this stymieing me? I am an idiot.
― akm, Monday, 9 August 2010 18:22 (fifteen years ago)
so the only reason this lecturer insists that i have to calculate today's date using the time.current.millis (or w/e haven't the book open) is because eh wants us to kill ourselves with this before beatifically smiling and saying "ah but that's why we have the java.util.date function" (or w/e i dont have the book open) because if so i gotta tell ya im not a fan of the sensei-makes-u-carry-water technique of teaching
― unblog your plug (darraghmac), Tuesday, 8 October 2013 16:28 (eleven years ago)
Well no, the reason you use epoch milliseconds is so you can manipulate datetimes without worrying about time zones
― Bitch Fantastic (DJP), Tuesday, 8 October 2013 16:31 (eleven years ago)
pretty sure that's java not javascript
― idembanana (abanana), Tuesday, 8 October 2013 16:37 (eleven years ago)
It was an hour out, i assumed the timezone (or summer time) was the difference tbh......
― unblog your plug (darraghmac), Tuesday, 8 October 2013 19:31 (eleven years ago)
metho taking in values for (char a, char b, int lines) and should print from a to b with a line break every 'lines' characters
{char x;int count=1;
for(x=a; x<=b; x++) { System.out.print(x +" "); count++; if(lines % count == 0) System.out.print("\n"); }}
i thought i'd passed a milestone last week when i started writing at work and emailing myself code for questions like this (and more complicated) that compiled and ran correctly first time when i got home. banged my head off the table on this POS last night for two hours and feel like it's all for nothing and i'll never be able to code, etc etc. managed to generate 'lines' number of each character from a to b, managed to generated a to b 'lines' number of times, who can tell me what'll happen when i run that above in about forty minutes?
― midwife christless (darraghmac), Tuesday, 5 November 2013 17:07 (eleven years ago)
I think you want count % lines not lines % count
― Just noise and screaming and no musical value at all. (Colonel Poo), Tuesday, 5 November 2013 17:13 (eleven years ago)
I was wondering about that and keep drawing a stupid stupid blank, i knew it last week i swear.
Ta for casting (eye) over it
― midwife christless (darraghmac), Tuesday, 5 November 2013 17:19 (eleven years ago)
Yeah, you want count % lines and I think you want to initialise count to 0, not 1.
― Just noise and screaming and no musical value at all. (Colonel Poo), Tuesday, 5 November 2013 17:19 (eleven years ago)
Just did this in Python to check it:
def f(a=1, b=100, lines=10): x = a count = 0 while x <= b: print "%s " % x, count += 1 x += 1 if count % lines == 0: print
That works.
― Just noise and screaming and no musical value at all. (Colonel Poo), Tuesday, 5 November 2013 17:21 (eleven years ago)
If you initialise count to 1, you'll get lines - 1 numbers on the first line
One question though, this is Java right? I'm not sure what happens if you do x++ when x is a char. Might be a type error of some kind? Shouldn't it be an int?
― Just noise and screaming and no musical value at all. (Colonel Poo), Tuesday, 5 November 2013 17:25 (eleven years ago)
No that works fine, char++ i mean
Smaller%bigger makes sense again now.
Ta
― midwife christless (darraghmac), Tuesday, 5 November 2013 17:39 (eleven years ago)
% is remainder after division so the order of the operands is the same as with /
Doing arithmetic with chars can lead to unexpected behaviour - the max value is going to be the max character code and idk if all operators are supported. int would be the natural type to use imo.
― snoop dogey doge (seandalai), Tuesday, 5 November 2013 19:00 (eleven years ago)
More info here: http://stackoverflow.com/questions/3680625/integer-arithmetic-in-java-with-char-and-integer-literal
We were given limits and direction, all i can tell you. Seems to go fine as long as you dont f/w user input (scanner doesnt like it, for instance)
― midwife christless (darraghmac), Tuesday, 5 November 2013 19:03 (eleven years ago)
Oh i guess if you're printing x as character output there's some sense behind it; I thought it was just a standard loop counter.
― snoop dogey doge (seandalai), Tuesday, 5 November 2013 19:05 (eleven years ago)
Yep zackly
Tho again without a user input option its p much a useless exercise but beginner lessons eh
― midwife christless (darraghmac), Tuesday, 5 November 2013 19:07 (eleven years ago)
yeah runs like dream, thks folks
― midwife christless (darraghmac), Tuesday, 5 November 2013 20:26 (eleven years ago)
what the fuck could possibly be wrong with this why is java such an ass
String[] names= new String[noOfStudents]; //ii. the students' names for(int i=0; i<noOfStudents; i++){ System.out.print("Enter name of student " +(i+1)); names[i] = input.nextString(); }
error at last line sez method nextString is undefined for type scanner- have looked about stack overflow and google as best i can but their answers tend to be just c&p'in code far in advance of where i'm at instead of explaining the issue or a workaround suitable to the level i'm at...
― 30 ch'lopping days left to umas (darraghmac), Tuesday, 26 November 2013 22:50 (eleven years ago)
First, javascript != java.
Second, quick glance here suggests that the proper method for getting a string from a Scanner object is .next(), not .nextString().
― Matt Groening's Cousin (Leee), Tuesday, 26 November 2013 22:56 (eleven years ago)
PS glancing through this thread, I assume that my first point has already been brought up.
― Matt Groening's Cousin (Leee), Tuesday, 26 November 2013 22:57 (eleven years ago)
sure has but nothing else presents itself
thanks!
― 30 ch'lopping days left to umas (darraghmac), Tuesday, 26 November 2013 22:59 (eleven years ago)
sorry
*runs code*i mean
THANKS!
― 30 ch'lopping days left to umas (darraghmac), Tuesday, 26 November 2013 23:01 (eleven years ago)
last part of the assignment we've been set wants us to compare questions entered into the console with a list of previous questions and check if that query has been asked already -if not, it will use wolfram alpha to answer the question and write new question/answer to separate files. if so, it will return the corresponding answer.
i can try to work out some sort of clumsy working of breaking down the question string into individual words and block all the 'ands, thes, whats, wheres' etc and running a search for what (hopefully relevant) words remain.
not got any idea of how to return the corresponding answer from the answer file.
but what i really wanna know is is there a simple way to solve these that i might be expected to know 12 weeks into a java course, i mean did i sleep through a one-line solution to this? cos i've been getting most of the week-to-week stuff done reasonable comfortably but this seems a big jump in terms of 'you're on your own here bub'
not looking for answers as in 'do my assignment' but any experienced thoughts on the concepts would be great, ta
― i kid because i glove (darraghmac), Wednesday, 1 January 2014 22:51 (eleven years ago)
Sounds to me like you can assume that, say, "1 + 2" and "sum of 1 and 2" are separate questions, unless he's specified otherwise.
I don't understand the file requirements. Is it one file for answers and one for questions? That sounds clumsy. Presumably you'd then have answer to the question on line 2 in line 2 of the answer file etc?I would probably have written it in a single file, with a line and answer per line, such as, say "1+2=3"
Have you been taught about maps? You could create a HashMap that contains all the questions and answered found so far. Every time someone submits a question, you see if the question exists as a key in the map already. If it doesn't, you submit it to Wolfram Alpha and add the question & response to your map.You'd have to write methods to read from file to map and write from map to file, of course. I'm not aware of any built-in Java trick for this. Well, unless you serialize the map using ObjectOutputStream and ObjectInputStream, but then I don't think your file will be human-readable (if that is at all a requirement)
― Øystein, Thursday, 2 January 2014 00:50 (eleven years ago)
thanks for looking in!
there are separate files for answers and questions (as set out per assignment description)
Have you been taught about maps? You could create a HashMap that contains all the questions and answered found so far. Every time someone submits a question, you see if the question exists as a key in the map already. If it doesn't, you submit it to Wolfram Alpha and add the question & response to your map.
heh this sounds perfect but haven't covered it- so i'm assuming he's looking for us to do the donkeywork so that we'll appreciate the shortcuts and be sure to remember them (this is how he's doing stuff so far)
im probably just going to do a lazy newquestionstring==(each oldquestionstring) to start with and at least get a structure up and running, then maybe start toying around with atomizing the new question, removing all prepositions etc and idk maybe string.contains() it.
we haven't done anything with regex, but it seems to be suggested as a possibly better way to do this?
we have 10% available for extra functionality, so if a workaround wasn't too much too learn in a couple of hours i'd be killing two birds with one stone by using a method we hadnt strictly covered.
― i kid because i glove (darraghmac), Thursday, 2 January 2014 00:57 (eleven years ago)
Yeah, always a good idea to just start off getting things in place, then rewrite once the basic functionality is in place.Regex can quickly become an unholy mess, but it depends a lot on what you're doing with it and how well you know the patterns you're looking for. It sounds like you'd be best off trying to make a helper method to "normalize" the question. E.g. normalize("1 + 2") would return "1+2" and normalize("What is the length of the Thames") would return, say, "length of thames".
― Øystein, Thursday, 2 January 2014 01:10 (eleven years ago)
im looking through the official java tutorials on regex now (ma ma look, i'm a real student) and it seems that (for my level at least) there's a lot of methods in java.lang.string that i could use just as easily, if i could get stuff (as you put it) normalized- i'll work on that much for now and see how it works out- cheers
― i kid because i glove (darraghmac), Thursday, 2 January 2014 01:28 (eleven years ago)
ok- wrote a few methods and have it up and running to do everything but locate the corresponding answer if a question has been asked previously- i have a count for this returned tho so it won't take but a few minutes to code that (hopefully)
that's just for exact matches of questions tho- i've asked for clarification on this so fingers crossed.
― i kid because i glove (darraghmac), Thursday, 2 January 2014 04:24 (eleven years ago)
Since this seems to have become the de facto Java thread, here goes.
I'm trying to create a GUI interface following MVC, and my model has a hashmap as one of its data members. On instantiation of the controller, that hashmap is properly loaded with the key-values that I fed it, but when I click on one of the buttons that's supposed to trigger an action that depends on the hashmap, the hashmap is null. Any ideas?
― Gibbering Hard Gibberish Soft (Leee), Monday, 17 March 2014 01:32 (eleven years ago)
And it looks like it's a problem with the hashmap itself, because a Vector member does exist. It's probably something with my code axing the hashmap, right?
― Gibbering Hard Gibberish Soft (Leee), Monday, 17 March 2014 01:37 (eleven years ago)
Oh god I found it, stupidly copy/pasted something from Stackoverflow.
― Gibbering Hard Gibberish Soft (Leee), Monday, 17 March 2014 01:39 (eleven years ago)
binary tree search has ruined my week
― recommend me a new bagman (darraghmac), Saturday, 5 April 2014 19:23 (eleven years ago)
Do we have any .NET programmers on ILX? I just started a job doing ASP.NET and I'm totally stuck getting EntityFramework to work on a project I've inherited. I'm at the point where I might just delete the whole thing and do everything in SQL, I'm so sick of battling with ORMs at the moment. It's only for what should be a very basic intranet page anyway.
See inner exception for details
InnerException: null
Fuck you Microsoft.
― Just noise and screaming and no musical value at all. (Colonel Poo), Thursday, 1 May 2014 09:54 (eleven years ago)
As good a place as any to ask,... thoughts on this (or similar)
http://devbootcamp.com/
― anvil, Thursday, 1 May 2014 11:46 (eleven years ago)