Jump to content

midnite

Members
  • Posts

    179
  • Joined

  • Last visited

Posts posted by midnite

  1. <html><head>  <script language="JavaScript">	function setTo(inherit, fontSize){	  inherit.style.fontSize = fontSize;	  inherit = inherit.childNodes;	  for (i=0; i<inherit.length; i++){		for (j=0; j<inherit[i].childNodes.length; j++){		  setTo(inherit[i], fontSize);		}	  }	}  </script></head><body>  <span id="title01" style="font-size:20px">Here <span style="font-size:90">is</span> the sample text</span><br>  <button onclick="setTo(document.getElementById('title01'), 10)">change to 10px</button></body></html>

    The above codes work fine. But if there is more than one <span> tag within, it will go wired :)

    <html><head>  <script language="JavaScript">	function setTo(inherit, fontSize){	  inherit.style.fontSize = fontSize;	  inherit = inherit.childNodes;	  for (i=0; i<inherit.length; i++){		for (j=0; j<inherit[i].childNodes.length; j++){		  setTo(inherit[i], fontSize);		}	  }	}  </script></head><body>  <span id="title01" style="font-size:20px">Here <span style="font-size:90">is</span> the <span style="font-size:50">sample</span> text</span><br>  <button onclick="setTo(document.getElementById('title01'), 10)">change to 10px</button></body></html>

    It is sort of infinitely looping. You may add some alert() functions into the function setTo() to break it, and to trace what is going wrong as well. Of course i did tried. i was working on it for hours and i still cannot find the way out!! Thanks for you help in advance :)

  2. <html><head>  <style type="text/css">	.custom {	  font-size: 20px;	  color: red;	}	.default {	  font-size: 10px;	  color: blue;	}  </style>  <script language="JavaScript">	function change(){	  document.getElementById("title02").className = "default";	}	function stripPx(text){	  return text.substr(0, (text.length>2 ? text.length-2 : 0));	}	function enlarge(){	  var elem = document.getElementById("title02");	  elem.style.fontSize = stripPx(elem.style.fontSize) * 1.5;	}	function back(){	  document.getElementById("title02").className = "custom";	}  </script></head><body>  <span id="title01" class="default">Here is the default text</span><br>  <span id="title02" class="custom">Here is the custom text</span><br>  <button onclick="change()">change to default</button>  <button onclick="enlarge()">enlarge the font</button>  <button onclick="back()">change to custom</button></body></html>

    one more question. If i want to enlarge it by 50%, what should i do? i found that i cannot access (retrieve) the value if it was set by css. Otherwise, if it was set by JS "elem.style.fontSize = 20;", then i can get the value "20" by stripping the "px" after. Is there a way to enlarge it for 50% from CSS, not from JS?and also, if i change the enlarge() function to:

    function enlarge(){	  var elem = document.getElementById("title02");	  elem.style.fontSize = 30;	}

    it works of course. But i cannot change it back by the function back().

  3. <html><head>  <style type="text/css">	.custom {	  font-size: 20px;	  color: red;	}	.default {	  font-size: 10px;	  color: blue;	}  </style>  <script language="JavaScript">	function change(){	  document.getElementById("title02").class = "default";	}  </script></head><body>  <font id="title01" class="default">Here is the default text</font><br>  <font id="title02" class="custom">Here is the custom text</font><br>  <button onclick="change()">change to default</button></body></html>

    here is my page and i want to change "title02" to the "default" CSS style. Please be noted that it DOES NOT WORK but it is just showing the idea. This is just an example so there is only two attributes "font-size" and "color". For real case, there will be a lot of settings. So changing the style one-by-one is not a wise choice. Is there a way to change them together like what the codes shown above?

  4. excuse me, let's say i have totally 10 seats numbered from 1 to 10 and people are randomly sitting on them.Yet, currently there are only 3 people and i have the table recorded:

    +------+------+|  ppl | seat |+------+------+| andy |	7 ||  jen |	4 ||  amy |	3 |+------+------+

    and now i would like to list out the blank seats

    +------------+| blank_seat |+------------+|		  1 ||		  2 ||		  5 ||		  6 ||		  8 ||		  9 ||		 10 |+------------+

    the idea is to list out the elements that the current table DO NOT have and its seat id is less than 10. i got the idea but don't know how to write the query. Thanks for helping in advance :]

  5. pulpfiction, you are really genius!!i not only get your answer, but also learnt from it!!

    mysql> SELECT * FROM ranking;+------+-----------+------+| rank | uni	   | area |+------+-----------+------+|	1 | Oxfrod	| UK   ||	2 | CamBridge | UK   ||	3 | UST	   | HK   ||	4 | Impreial  | UK   ||	5 | HKU	   | HK   ||	6 | MiB	   | UK   ||	7 | Impreial  | HK   |+------+-----------+------+7 rows in set (0.00 sec)mysql> SELECT uni, area, (SELECT COUNT(*) FROM ranking r2 WHERE r2.rank <= r1.rank && r1.area = r2.area) AS new_rank FROM ranking r1 WHERE r1.uni = 'Impreial';+----------+------+----------+| uni	  | area | new_rank |+----------+------+----------+| Impreial | UK   |		3 || Impreial | HK   |		3 |+----------+------+----------+2 rows in set (0.00 sec)

    see? i can do it if i want to list the local ranks of a particular university :]* Note that i am intended to spell them wrongly or using short forms that they are NOT referring to any real universities :P

  6. i am sorry if i didnt make it clear enough...i want it ranks in UK only.

    mysql> SELECT uni, rank AS area_rank FROM ranking;+-----------+-----------+| uni	   | area_rank |+-----------+-----------+| Oxfrod	|		 1 || CamBridge |		 2 || UST	   |		 3 || Impreial  |		 4 || HKU	   |		 5 || MiB	   |		 6 |+-----------+-----------+6 rows in set (0.01 sec)mysql> SELECT uni, rank AS area_rank FROM ranking WHERE uni = 'Impreial';+----------+-----------+| uni	  | area_rank |+----------+-----------+| Impreial |		 4 |+----------+-----------+1 row in set (0.00 sec)

    it gives me 4 instead of 3.

  7. for better descripe my problem, here comes an example:

    mysql> CREATE TABLE ranking (rank int primary key, uni varchar(20), area varchar(20));Query OK, 0 rows affected (0.01 sec)mysql> INSERT INTO ranking VALUES (1,'Oxfrod','UK'), (2,'CamBridge','UK'), (3,'UST','HK'), (4,'Impreial','UK'), (5,'HKU','HK'), (6,'MiB','UK');Query OK, 6 rows affected (0.00 sec)Records: 6  Duplicates: 0  Warnings: 0mysql> SELECT * FROM ranking;+------+-----------+------+| rank | uni	   | area |+------+-----------+------+|	1 | Oxfrod	| UK   ||	2 | CamBridge | UK   ||	3 | UST	   | HK   ||	4 | Impreial  | UK   ||	5 | HKU	   | HK   ||	6 | MiB	   | UK   |+------+-----------+------+6 rows in set (0.00 sec)mysql> SELECT uni FROM ranking WHERE area = 'UK' ORDER BY rank;+-----------+| uni	   |+-----------+| Oxfrod	|| CamBridge || Impreial  || MiB	   |+-----------+4 rows in set (0.01 sec)

    rank is the world rank of the uni. Now i want to find the rank of uni = Impreial in UK. If finding the world rank of Impreial, it is easy:

    mysql> SELECT uni, rank FROM ranking WHERE uni = 'Impreial';+----------+------+| uni	  | rank |+----------+------+| Impreial |	4 |+----------+------+1 row in set (0.00 sec)

    But now i want is to produce a table like this:

    +-----------+-----------+| uni	   | area_rank |+-----------+-----------+| Oxfrod	|		 1 || CamBridge |		 2 || Impreial  |		 3 || MiB	   |		 4 |+-----------+-----------+

    or more specific:

    +-----------+-----------+| uni	   | area_rank |+-----------+-----------+| Impreial  |		 3 |+-----------+-----------+

    Hope i have make it clear enough. Thanks in advance for any kindly help :]

  8. yes, it's true. Every software have some special alterations, that they will add some self-developed functions that they think those will make the queries run faster and smoother. So, in another words, their SQL are not that standard. But you need not worry. The basic stuff are all the same :)

  9. first of all, really a BIG THANKS to Yahweh!! You really genius!!aspnetguy and jesh, also thanks very much for your help.in fact, what i want to do is to keep the list tidy. Let's say there are 5 rows and originally their id are 1 to 5. If id=3 have left, the list will become 1,2,4,5. So i would like to make it to 1,2,3,4. Hope you understand :]For instant, i have think of two approaches.1) using AUTO_INCREMENTwhenever a row is deleted, change the largest id to the one deleted if the id of the row being deleted is less than the largest id.(exceptional case occurs when the largest row is the one being deleted. 1,2,3,4,5 -> 1,2,3,4 -> 1,2,3,5)then set AUTO_INCREMENT to the id being deleted.(in the first case, 1,2,3,4,5 -> 1,2,4,5 -> 1,2,3,4 and set AUTO_INCREMENT = 3. The AUTO_INCREMENT will be 5 but not 3)2) not using AUTO_INCREMENTwhenever a row is deleted, fill it in with the largest. It is just the same here with method 1.when a row need to be insert, find the maximum and insert it at the max+1. That is what i was asking.method 1 won't work in some of my tables because they have more than one column require this kind of operation. MySQL doesn't allow me to specify more than one AUTO_INCREMENT column.also for performance considering, setting AUTO_INCREMENT to a low value, then MySQL automatically enlarge it to the appropriate value. This may be a slow process. Also whenever we set the AUTO_INCREMENT, we will notice that ALL the rows of the table are affected!!

    mysql> ALTER TABLE acc_list AUTO_INCREMENT = 5;Query OK, 10 rows affected (0.09 sec)Records: 10  Duplicates: 0  Warnings: 0

    so, the second method will probably be better. Am i right?

  10. aspnetguy:MySQL still complaining that the same table cannot appear in both INSERT and the FROM clause..it seems that MySQL and Access are using something quite different.Yahweh:Oh thanks!! It works fine.But how to alter the SQL if my table got more than one column? The one i raised is just an example and make things simpler. The real thing of course having many columns, a single one can do nothing.

  11. excuse me, how to insert one row right after the largest one?for example:

    +----+| id |+----+|  1 ||  2 ||  3 ||  4 |+----+mysql> INSERT INTO acc_list VALUES ((SELECT max(id) FROM acc_list)+1);+----+| id |+----+|  1 ||  2 ||  3 ||  4 ||  5 |+----+

    this is a fake one of course. The SQL is incorrect! But it at least showing the concept and let you understand my problem. It can be done by two queries. But making it in one single query can prevent some errors and speed up performance.It can also be done by AUTO_INCREMENT. But in my case, using AUTO_INCREMENT will not be that handy.

  12. oh sorry, it gives me this

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY ac1.id' at line 1

    i just wonder if UPDATE queries can use GROUP BY ?

  13. this shouldnt be a difficult problem, and it is quite typical. But just i cant find my way outit is just referring to its own table. as stated in the mysql doc

    Another restriction is that currently you cannot modify a table and select from the same table in a subquery. This applies to statements such as DELETE, INSERT, REPLACE, UPDATE, and (because subqueries can be used in the SET clause) LOAD DATA INFILE.
    and here seems to be explaining and solving the problem by INNER JOIN. But i dont get it.in fact, what i want to do is: updating the maximum value to a certain value.it will be very nice if the follow query works, but it doesnt!
    UPDATE acc_list SET id = 7 WHERE id = (SELECT max(id) FROM acc_list);

    so i tried the JOIN method, but it says Invalid use of group function

    UPDATE acc_list ac1 inner JOIN acc_list ac2 on ac1.id = max(ac2.id) SET ac1.id = 7;

    here's a detailed graphical explanation for my problem:

    +----+			  +----+| id |			  | id |+----+			  +----+|  1 |			  |  1 ||  2 |  changes to  |  2 ||  3 |			  |  3 || 18 |			  |  7 |+----+			  +----+

    footer

    Thanks very much. what i want is actually not a page with fixed height. i stick back to the <TABLE> method and now everything is fine :)

    footer

    how can i make a footer that's *ALWAYS* visually bottom of the page?if the content is short that no scrolling is required, the footer text will stick to the bottom of the page likes what we do with the scripts

    position: absolute; bottom: 0;

    if the content is long that need scrolling, the footer text will just as if it is appending to the end of the pagei know that <TABLE> can do it, yet is there a style sheet method??

  14. oh.. i see. i did have a wrong concept towards grouping selectors. Grouping selectors are *just* for the reason that they all share the same properties. But *NOT* taking any "common factors" of the selectors. Such as

      .abc xxx, yyy { color: red; }

    is equivalent to

      .abc xxx { color: red; }  yyy { color: red; }

    but *NOT*

      .abc xxx { color: red; }  .abc yyy { color: red; }

    me gotta be careful from now on :)

  15. can it be "lesser"?as

    	a:hover { text-decoration: underline; }	a:active { text-decoration: underline; }

    can be grouped as

    	a:hover, :active { text-decoration: underline; }

  16. excuse me, how can i know my CPU Front Side Bus Speed if my CPU is already not on the list of the vendor's hit items? For instant, my notebook is a P4 M with 2.00GHz, family 15, model 2, stepping 7 (i don't know all these yet i hope they help). i can't find any matches in the site of Intel. And one more, my old old desktop having a AMD K6 3D processor, 64 KB Cache, CPU family 5, model 8, and running Gentoo Linux.For the RAM, i can't find any label (physically) on some of my RAM. How can i know their speed?i did try to find those speed, of CPU FSB and RAM, in the BIOS while boot, yet i failed as there is no such information in it.And more, on some computers' BIOS, there shows the CPU temperature, yet i can't find any in the OS (both Windows and Linux) :)Anyone can provide Windows' or Linux's method will be fine. Both, is the best of course :)Thanks very very much!!

  17. icable, hong kong.i wonder if it is due to the taiwan earthquake days ago, that makes us clients can "go out" of hong kong ..n i wonder why it will sometimes can but sometimes get blocked ??the proxy IP is always 222.166.160.xxx , with xxx is changing nearly ALL the time ..

×
×
  • Create New...