Jump to content
xisto Community

galexcd

Members
  • Content Count

    1,313
  • Joined

  • Last visited

About galexcd

  • Rank
    Trap Grand Marshal Member

Profile Information

  • Gender
    Not Telling
  1. Sorry, it took a while to get back to you. I've been quite busy the past few days. Anyway, I wrote up a quick and minimal javascript function to do all the work you want for you. It supports any level drop down boxes, so if you want to add a 4th drop down box, it should work just fine. Basically to get it working all you have to do is set up your select options in the way described below, and then copy and paste the block of javascript code somewhere after your select boxes. To set up the select options, first, add onChange="update(this)" as an attribute to the select element. Then for each select element, add all possible options under that element and set the class equal to the value of the prerequisite. Here is a simple example: <form name="formname" method="post" action=""> <select name="one" onChange="update(this)"> <option value="">Select #1</option> <option value="numbers">Select Numbers</option> <option value="letters">Select Letters</option> </select> <select name="two" onChange="update(this)"> <option value="">Select #2</option> <option value="1" class="numbers">1</option> <option value="2" class="numbers">2</option> <option value="3" class="numbers">3</option> <option value="a" class="letters">a</option> <option value="b" class="letters">b</option> <option value="c" class="letters">c</option> </select> <select name="three" onChange="update(this)"> <option value="">Select #3</option> <option value="1.1" class="1">1.1</option> <option value="1.2" class="1">1.2</option> <option value="2.1" class="2">2.1</option> <option value="2.2" class="2">2.2</option> <option value="3.1" class="3">3.1</option> <option value="3.2" class="3">3.2</option> <option value="a.1" class="a">a.1</option> <option value="a.2" class="a">a.2</option> <option value="b.1" class="b">b.1</option> <option value="b.2" class="b">b.2</option> <option value="c.1" class="c">c.1</option> <option value="c.2" class="c">c.2</option> </select></form>In this example, we want the options a,b, and c, to show up when the user selects "letters" under the first drop down. Therefore, we set the class equal to "letters". Etc... And here is the javascript to be inserted anywhere after the select options: <script type="text/javascript">var s=Array();var c=Array();var a=document.getElementsByTagName("select");for(i=0;i<a.length;i++){ b=a[i].options; s[i]=Array(); c[i]=Array(); for(j=0,k=0;j<b.length;k++){ s[i][k]=b[j]; c[i][k]=b[j].className; if(c[i][k]!="")b[j]=null; else j++; }}function update(obj){ for(n=0;n<a.length && obj!=a[n];n++); if(++n>=a.length)return; while(a[n].options.length>1)a[n].options[1]=null; for(i=0;i<s[n].length;i++) if(c[n][i]=="" || c[n][i]==obj.value) a[n].options[a[n].options.length]=s[n][i]; a[n].value="";}</script> And now putting it all together using your structure of countries->airports->cities... <form name="formname" method="post" action=""> <select name="Country" onChange="update(this)"> <option value="">Select Country</option> <option value="Spain">Spain</option> <option value="Turkey">Turkey</option> <option value="Greece">Greece</option> </select> <select name="Airport" onChange="update(this)"> <option value="">Select Airport</option> <option value="Barcelona" class="Spain">Barcelona</option> <option value="Gerona" class="Spain">Gerona</option> <option value="Malaga" class="Spain">Malaga</option> <option value="Alicante" class="Spain">Alicante</option> <option value="Madrid" class="Spain">Madrid</option> <option value="Antalya" class="Turkey">Antalya</option> <option value="Bodrum" class="Turkey">Bodrum</option> <option value="Dalaman" class="Turkey">Dalaman</option> <option value="Istambul" class="Turkey">Istambul</option> <option value="Rhodes" class="Greece">Rhodes</option> <option value="Athens" class="Greece">Athens</option> <option value="Heraklion" class="Greece">Heraklion</option> <option value="Corfu" class="Greece">Corfu</option> <option value="Zante" class="Greece">Zante</option> </select> <select name="City" onChange="update(this)"> <option value="">Select City</option> <option value="Barcelona was selected #1" class="Barcelona">Barcelona was selected #1</option> <option value="Barcelona was selected #2" class="Barcelona">Barcelona was selected #2</option> <option value="Rhodes was selected #1" class="Rhodes">Rhodes was selected #1</option> <option value="Rhodes was selected #2" class="Rhodes">Rhodes was selected #2</option> [Replace me with more options for each airport...] </select></form><script type="text/javascript">var s=Array();var c=Array();var a=document.getElementsByTagName("select");for(i=0;i<a.length;i++){ b=a[i].options; s[i]=Array(); c[i]=Array(); for(j=0,k=0;j<b.length;k++){ s[i][k]=b[j]; c[i][k]=b[j].className; if(c[i][k]!="")b[j]=null; else j++; }}function update(obj){ for(n=0;n<a.length && obj!=a[n];n++); if(++n>=a.length)return; while(a[n].options.length>1)a[n].options[1]=null; for(i=0;i<s[n].length;i++) if(c[n][i]=="" || c[n][i]==obj.value) a[n].options[a[n].options.length]=s[n][i]; a[n].value="";}</script> Additional notes:I wrote this javascript myself from scratch. Anyone can use it for any reason without giving any credit to me. (I hate people who write simple code like this and add their name in the comments. I mean seriously, you didn't write a library, it's a simple piece of code that took 30 seconds to write... </rant>) Post-post script: I know my coding style isn't very readable, but this is ideally how people should write javascript. Javascript is interpreted therefore you should write it as minimal as possible to cut down on loading times. Consider yourself lucky that I didn't remove all whitespace and semicolons before close brackets.
  2. Easiest way of doing it without changing the structure of your code too much would be to just copy your dropdownlist function, and use that to check for changes on the second drop down list. Then create a third select element and hook the onchange attribute of the second select element to call the new javascript function you created. It's a bit messy, I'd probably do it a different way. If you want me to I could write you some cleaner code to do this for you when I get home from work tonight.
  3. Topic is resolved.Please PM any moderator to continue this discussion. Until then, this topic is closed.
  4. It's not windows at all. His desktop environment is KDE. I'm more of an xfce guy so we are naturally rivals. However we come together with our mutual dislike of windows. I was actually going to edit the image to make it look like windows was running in a VM under opensuse with xfce, (but I was too busy to do it in time). I believe TF was going for more of a wine look with the hybrid windows/linux screenshot. Either way, this post is FAR too late for anyone to actually bother reading since what it's referring to is on the previous page. So, in that case I suppose I'll just stop here and move along. Nothing to see here.
  5. Thank you so much for your kind birthday wishes! :D

  6. It turns out that this house is a mere 200 feet from the Nevada test site! Also, I just have to say....... Hidden
  7. Hello vkthiru, and welcome to our forum. Avalon provided a cross-browser compatible pure css solution that I would recommend using over the OP's script. I have quoted this solution below:
  8. And members like me with a full-time job and 19 unit school semester get to lose their accounts? I don't really mind about losing mycents since I'm not using them, but I would be rather annoyed if my account were deleted because I haven't had time to sit down and log in to my account in the past month.
  9. Since everyone seems to have an abundance of Google Wave invites, this topic is no longer relevant or useful. Therefore I am closing this topic. PM a moderator if you wish to continue discussion.
  10. I completely agree, storing your company's private email data on gmail's webservers seems like it could have potential legality issues. Any business and school should use their own servers for something as important as email. However I am beginning to see many small businesses and schools start to use google apps for their employee/student email.
  11. Re your personal statement:

    (Girls are like internet domain names: the ones I like are already taken.)

    You can still get one from a foreign country :P

  12. Google's April fools did not match up to their usual goodness. However, they added some neat things to some of their other products like Youtube's text mode, Google doc's cloud for your keys/remotes, and Google Wave's actual human notifications. However I think that google doesn't take the cake this year for the best April Fools joke. reddit has added the ability for everyone to be an admin, which is really clever. However, my favorite by far would have to be XKCD's unix-like terminal (hint: type in emacs, and vim hahaha). Edit: in XKCD type in "make me a sandwich", then type in "sudo make me a sandwich" HAHAHAHhahaha
  13. I completely disagree. I think even if the final result is uninteresting it still is a great learning experience and most likely increased the OPs proficiency in whatever image manipulation software he or she uses. As for my critique of the image itself, I think it was composited very well. The added fur below the jaw really has some depth to it. I look forward to seeing the final draft of the image.
  14. Demo100, please note that some sections of the forums such as web design do not display your post immediately. A moderator must approve it first. Please do not repost the same topic multiple times because they did not show up right away.
  15. Zagubadu is referring to the rich text editor I believe. I don't think it has anything to do with quoting, other than when you want to quote someone you must use the full rich text editor rather than the fast reply standard text area. The rich text editor actually uses frames to render your text as you are editing it, while the simple <textarea> of fast reply only displays bbcode. Normally this method of rendering your post while you type works fine. However perhaps some update in your browser or some change to the website broke it. I am actually having the same issue with the rich text editor at the moment. Since I almost always use the fast reply I'm not sure when this issue started for me, however I recently updated Firefox to 3.6. Looking at the source for the frame leads me to believe it may be some issue with the website because if I recall correctly to allow a page to be editable you must include a line of java script: document.designMode="on"... again, i may be wrong (it's been ages since I wrote my own rich text editor). Or there may be a new better way of doing it using pure css/html5. Edit: After a quick Google search I found that there is a newer way of doing this: <html id="ed-0_html"> And the frame does implement it, so perhaps this method has some issues in Firefox?
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.