I am using the following for a different picture to show up every day....
<script language="JavaS cript">
<!--
function adspic() {
var mydate=new Date()
var day=mydate.getD ay()
var month=mydate.ge tMonth()
var daym=mydate.get Date()
if (daym<10)
daym="0"+daym
var adspicarray=new Array("ads/images/kilt.jpg",
"ads/images/kilt.jpg",
"ads/images/kilt.jpg",
"ads/images/apronandcase.jp g",
"ads/images/kilt.jpg",
"ads/images/apronandcase.jp g",
"ads/images/apronandcase.jp g")
document.write( "<p align='right'>< img src = '" + adspicarray[day] +
"'/>")}
// -->
</script>
Question (1)
How do I do it so that it is random??
Question (2)
How do i make it so that [day] can be used in other functions (currently i
use the same 'var' sequence in each function
May 27 '06
15 1465
JimK wrote on 29 mei 2006 in comp.lang.javas cript: John Stockton: R = Math.random()*5 |0
I like it, would have never thought of that method. Randy has already pointed out the problem using Math.round(Math .random() * 6
I like it too, but it is EATING my <br>s:
try:
<script type='text/javascript'>
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
document.write( Math.random()*5 |0 + '<br>' );
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"VK" <sc**********@y ahoo.com> writes: Would it lead to implications if used in the reverse order? 0|510
Bitwise or is symmetric. It converts both operands to 32-bit integers
before operating on them. Then the result is converted back to a
64-bit floating point number (although an optimizing implementation
might choose to keep it as an integer until "floatness" is needed)
In such case it could be used as a pseudo-allocator to use together with say 0x1FE and 0776
Not understood. Both of these number literals represent values of the
number type, i.e., floating point numbers.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
"Evertjan." <ex************ **@interxnl.net > writes: I like it too, but it is EATING my <br>s:
try:
<script type='text/javascript'> document.write( Math.random()*5 |0 + '<br>' );
The + operator has higher precedence than the bitwise or operator,
so this expression is equivalent to:
(Math.random() * 5) | (0 + '<br>')
The second operand of "|" is the string "0<br>", which converts
to the number NaN, which converts to the 32-bit integer 0.
So, that's what's eating your "<br>".
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Mon, 29
May 2006 09:02:50 remote, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted : JimK wrote on 29 mei 2006 in comp.lang.javas cript:
John Stockton: R = Math.random()*5 |0
I like it, would have never thought of that method. Randy has already pointed out the problem using Math.round(Math .random() * 6
I like it too, but it is EATING my <br>s:
try:
<script type='text/javascript'> document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); document.write ( Math.random()*5 |0 + '<br>' ); </script>
Whenever an expression (such as the RHS of my "R =") is placed within
another expression, it should be put in parentheses unless those
parentheses are known not to be needed. Example :-
R = 1 + 2
S = "3 = " + R // OK
S = "3 = " + 1 + 2 // not OK
S = "3 = " + (1 + 2) // OK
Bitwise OR is of low precedence, so that most other operators are
executed before it, and therefore B-OR prefers to eat well-chewed
operands.
R = 0|Math.random() *5
is probably better, since 5|0 looks like 510. Fortunately, there seems
to be no binary ! operator nor unary | .
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr John Stockton wrote on 29 mei 2006 in comp.lang.javas cript: I like it too, but it is EATING my <br>s:
try:
<script type='text/javascript'> document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); document.writ e( Math.random()*5 |0 + '<br>' ); </script>
Whenever an expression (such as the RHS of my "R =") is placed within another expression, it should be put in parentheses unless those parentheses are known not to be needed.
I love those quircks in a computer language,
like this "eating of the <br>s".
It makse them more alive and more like a real language.
However, the real culprit here is having "+" as a string concatenation
operator.
Having the "+" as "add" having precedence over "|" stands to logic,
but "+" as "concatenat e" should not have that precedence, me seems.
Since that cannot be, let us at least enjoy it.
==========
When God said to the beasts "go and multiply",
one pair came up to him and complained:
"We cannot multiply, we are only adders"
And then they said:
"And we want unparenthesed precedence over those slimy concatenators too"
In the end the lonely unary "+" was given top precedence to compensate
for it's total lack of both multiplication and adding power.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Tue, 30
May 2006 08:00:21 remote, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted : I love those quircks in a computer language, like this "eating of the <br>s".
It makse them more alive and more like a real language.
However, the real culprit here is having "+" as a string concatenation operator.
Nothing wrong with that; the culprit is having "+" accept non-matching
operands.
Binary + should accept only two strings or two numbers.
Unary + should accept anything, and convert it to Number.
Unary - should give the negative of unary +.
There should be a new unary operator (for brevity), to accept anything
and convert to String.
Except, of course, that it is too late now.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: raver2046 |
last post by:
hello,
How to have a global var in python ?
thank you.
raver2046
http://raver2046.ath.cx
|
by: rlo |
last post by:
use the next script:
var answers0 = new Array(
(answer11),
(answer12),
(answer13),
(answer14) );
question= new geefVraag( 0,
'question1', oke1-1, answers0);
feedback= new Array(
|
by: Maja |
last post by:
Greetings,
/var/adm/wtmp files were getting out of hand
and I wanted to filter the file rather than zeroing it out.
I found some code that would only keep the last x days
but it required creating a temporary file in /tmp
and then copying it back to /var/adm. I rewrote the code
to load the contents of the wtmp file into memory and then
write the filtered records in memory directly back to /var/adm/wtmp,
eliminating the need for a...
|
by: Thierry Loiseau |
last post by:
Hello all,
and Happy end year 2005 !
Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?
That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :
|
by: overdalsveien |
last post by:
hi
This is probably elementary, but since my 'Dear Watson' is not present
I hope you folks can help me::
---------------------------
var dag = date1.getDate();
document.getElementById("selDay1").innerHTML =
makeRequest('test.php?d=1');
-----------------------------------------------
| |
by: vlsidesign |
last post by:
If I have a "for" loop like this:
for (i = 0; i < 10; i++)
or like this
for (i = 0; i < 10; ++i)
both of the "for" loops will function the same. I also noticed if I use
a variable called j within the "for" loop body, and put these statement
in the "for" loop body like this:
printf("j var is: %d\n", ++j);
printf("j var is: %d\n", j++);
In the first statement, "j" increments first, and then prints "j"
|
by: Rainy |
last post by:
I have a stylistic question. In most languages words in var. name are
separated by underscores or cap letters, resulting in var names like
var_name, VarName and varName. I don't like that very much because all
3 ways of naming look bad and/or hard to type. From what I understand,
scheme can have variables like var-name. I'm curious about reasons
that python chose to disallow this. Another question I have is what
other languages allow this...
|
by: DL |
last post by:
For instance,
function addNew(i) {
var 'element'&i
...
}
If possible, how to?
Thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |