Jump to content


  • Posts

  • Joined

  • Last visited

spoonraker's Achievements


Newbie (1/7)



  1. You will learn to love the ability to write plain HTML that is conditional on PHP. These examples are all very simple and when you look at them the echo statments don't seem to make the code any different, but imagine on a larger scale.What if you have an entire huge section of page that is only set to display if a PHP variable is true? would you want echo, echo, echo, echo, echo, echo, echo, echo... for a bazillion lines? Or would you rather just have<? if(something){ ?><table><tr><td><font><whatever><blah>....etc<? } ?>
  2. problem solved! thanks for all the input
  3. Ok well it turns out my script works just fine, I'm just getting strange errors with select boxes not having properties and stuff.I'm using this DynamicOptionList javascript function to handle my dynamic lists. http://www.mattkruse.com/javascript/dynamicoptionlist/When I reference a select box that I manually create and add options to, both the getIndexOfValue() and changeSelect() functions work fine, but when I pass it a select box handled by that script, it always tells me that "selectBox has no properties" even though I can see all the options on my screen.
  4. YepSo nobody knows why it's not working and/or has another way to do it?
  5. I have narrowed my problem down to the getIndexOfValue() method.If I just call changeSelection(whatever, 2), it works just fine.Thanks for any help.*update* I noticed in this line for (i = 1; i < selectBox.options.length; i++) { that I forgot the "var" in the for loop, I changed it to for (var i = 1; i < selectBox.options.length; i++) { It still doesn't work.Oh and I get zero javascript errors.
  6. I'll make this simple...this web page I'm working on is incredibly huge and complicated (I'm well over 2,000 lines of Java) and trying to post the "big picture" would just confuse the ###### out of everybody...so here is exactly what I need.I have a select box like so...<select id="filter"><option value="blah">blah</option><option value="bleh">bleh</option><option value="bluh">bluh</option></select>The ONLY data I have to work with is the "value" of the option selected, "blah", "bleh", or "bluh".So how would I use javascript to select the correct option?The method I'm currently trying uses a reverse lookup. It loops through the options one at a time, and when the value matches the value I pass in, it returns the index of that option. Then I use document.getElementById("filter").options.selectedIndex = X to set the selectbox to the correct option.The code for that is posted in the OP, but it's not working.
  7. Ok, this is a little complicated so bear with me and try and understand my problem.I have a website with 3 dropdown menus. The first one is a filter, things like name, rank, etc. The second one is an operator for that filter, either =, >, or <. The third one is a list of options for a particular filter, for example if you select rank as the filter you get options like Affiliate, executive, etc.Now... in case you didn't figure this out on your own, the first dropdown is static, and the other two are dynamic based on what you chose in the first. I have absolutely no trouble generating these menus, that has been in place for a while.What my problem is, is that when the form is submitted, I need the refreshed page to pre-populate those forums with the saved data.The data for the three drop downs (Dropdown IDs in order : "filterby", filterbysize", "filterbyvalue") is stored in Java/JSP.So...I created a javascript function which was supposed to run on page load using the body onLoad tag.Well the first problem is that my javascript function doesn't work. What I planned on doing was doing a reverse looking up the select option indexes by value, and then passing that index to a function which sets that select to that option. Here is my code, now I know that it's a little bit different than I described, this is because there is another set of filters, the first one has a text field as the last option, and the second one is the one I described with three select menus. function getIndexOfValue(selectBox, lookupValue){ var index = 1; for (i = 1; i < selectBox.options.length; i++) { if (selectBox.options[i].value == lookupValue) { index = i; } } return index; } function changeSelection_(selectBox, index){ selectBox.options.selectedIndex = index; } function populateFilters(){ var filterbysize = document.getElementById("filterbysize"); var filterbysizevalue = "<%=genealogy.getFilterbysize()%>"; var filterbysizetwo = document.getElementById("filterbysizetwo"); var filterbysizetwovalue = "<%=genealogy.getFilterbysizetwo()%>"; var filterbyvaluetwo = document.getElementById("filterbyvaluetwo"); var filterbyvaluetwovalue = "<%=genealogy.getFilterbyvaluetwo()%>"; changeSelection(filterbysize, getIndexOfValue(filterbysize, filterbysizevalue)); changeSelection(filterbysizetwo, getIndexOfValue(filterbysizetwo, filterbysizetwovalue)); changeSelection(filterbyvaluetwo, getIndexOfValue(filterbyvaluetwo, filterbyvaluetwovalue)); } The function be to run at page load is populateFilters(). Using alerts I have determined that the code stops executing once it hits the last three changeSelection(... commands. If I comment those out and place an alert after all the variable declarations it works fine. Also, the jsp <%= %> statements aren't the problem, they work fine, i can print out the values using a JS alert.So that's my first problem, my reverse lookup and option changing scripts dont work. Any ideas?No my second problem is pretty simple. The body onLoad tag doesn't work. If I do body onLoad="populateFilters()", nothing happens. Even if I do body onLoad="alert('hello')" I never see the alert. But when I take my populateFilters() function and execute it in an onClick event, it executes fine (except the errors talked about above obviously)Any help is appreciated
  8. First of all, this is a linux question and not in any way related to Java programming.Now, to answer your question. When you compile something with the -classpath parameter, it's not permanent. As you said, every time you type the command in you will have to type the classpath again. What we use here is "ant" which is a build tool that automates the compiling of the entire directory. Why don't you just use a batch file or something like ant? Even with our huge codebase it only takes at most 20 seconds for a complete compile.
  9. Answer given on another forum, worked great, just thought others might want this info in case they have a similar problem.Steps :1) Create a TreeMap and store values in it.2) Create a List with values from TreeMap.entrySet().3) Implement Comparator interface and apply your camparison constriants.4) Sort the list.So just do as follows:Create 1 class with name : sortValues.javaimport java.util.ArrayList;import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.TreeMap;public class sortValues{public static void main(String args[]){TreeMap hm= new TreeMap();hm.put(new Integer(100),new Integer(1000));hm.put(new Integer(200),new Integer(900));hm.put(new Integer(300),new Integer(800));hm.put(new Integer(400),new Integer(700));hm.put(new Integer(500),new Integer(600));hm.put(new Integer(600),new Integer(500));hm.put(new Integer(700),new Integer(400));hm.put(new Integer(800),new Integer(300));hm.put(new Integer(900),new Integer(200));hm.put(new Integer(1000),new Integer(100));hm.put(new Integer(1100),new Integer(100));hm.put(new Integer(10),new Integer(10));List entrylist = new ArrayList(hm.entrySet());Collections.sort(entrylist,new ValueComparator());Iterator i = entrylist.iterator();while(i.hasNext()){System.out.println(i.next());}}}Another class : ValueComparator.javaimport java.util.Comparator;import java.util.Iterator;import java.util.Map;class ValueComparator implements Comparator {public int compare(Object o1, Object o2) {Map.Entry e1 = (Map.Entry) o1;Map.Entry e2 = (Map.Entry) o2;Comparable c1 = (Comparable)e1.getValue();Comparable c2 = (Comparable)e2.getValue();return c1.compareTo(c2);}}***Note*** : Your ending list will be of the type Map.Entry. To get a listing of just the ID values you will have to cast them properly. If you are iterating through the list, it would be like this ((Integer)((Map.Entry)iterataor.next()).getKey()).intValue()
  10. http://www.mattkruse.com/javascript/dynamicoptionlist/
  11. the best thing I can come up with is to create a hashtable which uses a simple ascending integer list as keys, and the ID as the values, then make a vector of the data to be sorted, using the same indexes as the hash table. Copy that vector and sort it, then iterate through the sorted vector and perform a reverse lookup (pull the index) on the non-sorted vector, then use that index to reference the hashtable and finally pull out the SFIID.This will work I'm sure of it, but this can't possibly be that complicated. I know I'm not that first person that has needed to sort a map by the value rather than the key.
  12. Now, I'm not completely stupid, I know how to just straight up sort a list of integers, but this is more complicated.What I need to do, is take a list of IDs (not the integers being sorted), iterate through that list and pull out the number associated with each ID from a MySQL database, sort the numbers, and then output a list of just the IDs, sorted by the number previously pulled out.I had this same problem before, only the data being sorted was a string. So what I did was create a hashtable. I made the String to be sorted (with the ID appended on the end) the key, and I made the ID the value. I created a vector from the key set, sorted it, and then iterated through it to pull all the values out of the hashtable (IDs) into a new sorted vector, it worked great.However now that I'm dealing with numbers, things are complicated. Hashtables can not have duplicate keys, and before I just appened the ID onto the string to be sorted, but if I do that with an integer it will create a new number and throw off the sort. I can not handle it as a string and them remove the appended part when I go to sort either, because then I lose my original key to look up the IDs after the sort. Also, I can not switch my hashtable data (make the ID the key and the sorted data the value) because Hashtables don't have any reverse lookup methods. i.e. I can't send in a value and return the key.Somebody recommended that I try a LinkedList, which sounded good after a bit of reading, but it didn't work either. I need to keep the IDs linked to the numbers, so when I try to use the ID (which is an int btw) as the index and the number as the value, I got IndexOutOfBounds exception. The IDs are 6 or 7 digit numbers, so I don't think just allocating a ton of space to it would be a good idea, when probably no more than a few hundred indexs will be assigned values.So.....any ideas?I need something that will link an ID (can be String or int) to an integer value, allow me to pull the numbers out and sort them, and then reference the IDs using the values from the sorted list as the lookup criteria.
  13. spoonraker


    If it is homework, I don't mind helping, but I'm not going to just do it for him.A basic idea of what needs to be done :Create a page with the proper formWhen the form is submitted, capture the variables from the request. request.getParameter()Calculate stuff. If you can't do this part without any help, you're in over your head with this project
  • Create New...