Help - Search - Member List - Calendar
Full Version: LANGUAGE QUESTION
WorkTheWeb Forums > Webmaster Resources > JavaScript Help
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
Support our Sponsors!


David
Do you not think that with the .net environment that there is little to
distinguish C# from VB? What do you see as the significant differences?

David Evans (Dajuroka.com)
"Samir Talwar" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
Go for C#. It's the only one with a real money-making oppurtunity.
Samir Talwar

[Email Removed] (Pupppy Wizzard) wrote in message
news:<[Email Removed]>...
Hi. I am an old school programmer looking to modernize my skill set. I
want to focus on one new language. Should I choose:

VB
VB.net
C#
J#
JScript.net
or Java?


Laurent Bugnion, GalaSoft
Hi,

David wrote:
QUOTE
Do you not think that with the .net environment that there is little to
distinguish C# from VB? What do you see as the significant differences?

David Evans (Dajuroka.com)
"Samir Talwar" <[Email Removed]> wrote in message
news:[Email Removed]...

Go for C#. It's the only one with a real money-making oppurtunity.
Samir Talwar

[Email Removed] (Pupppy Wizzard) wrote in message

news:<[Email Removed]>...

Hi. I am an old school programmer looking to modernize my skill set. I
want to focus on one new language. Should I choose:

VB
VB.net
C#
J#
JScript.net
or Java?

Don't mix VB and VB.NET, there is a huge difference between them.

First of all, C#'s syntax is based on the C-syntax, which is more modern
and simply makes more sense.

Second, the C# development environment is more advanced than the VB.NET
development environment, for example for the inline documentation, or
the integration of Rational XDE.

In the past, the only advantage of VB was the ease of developing new
applications, especially building UIs. Nowadays, this ease also exists
in C#. There is thus no real reason to keep on learning VB.NET, except
of course for programmers who know only VB and don't want to do the step
to C#.

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Doug Miller
In article <8OwKa.441$[Email Removed]>, "David" <[Email Removed]> wrote:
QUOTE
Do you not think that with the .net environment that there is little to
distinguish C# from VB? What do you see as the significant differences?

Please trim rec.woodworking from your followups. Thanks.


Lasse Reichstein Nielsen
Dom Leonard <[Email Removed]> writes:

QUOTE
differ in their Scope chains, and when you create them inside the same
function body during one call to that function, then the scope chains
will also be identical.

Perhaps theoretically possible, but I find no evidence that either IE6
or Moz 1.3 "join" function objects as described in ECMA 262, and in
practice a new function object is created for every execution of an
inner function definition of the form

I think they do join objects in some cases, but it was not that kind
of indistinguishability I was referring to.

The two distinct functions are indistinguishable *as functions*
(extensionally). There is no way the code in the body of the function
alone can act different - it refers to the same variables and contain
the same code, even though the function objects might not compare
equal with == or ===.

When calling the functions with identical arguments, there are only
two things that differ during execution of the function body: The
value of the "this" keyword (if they are methods of different objects)
and the value of arguments.callee (the function object itself).

To make the functions act differently, you must use one of these.
Either treat them like objects (adding properties to the function
object) or using that they are methods of different objects (attaching
information to the "this"-object).


Joining of functions (which I hadn't read in detail before) is
actually interesting.

Compare
---
var x=[];
for (var i=0;i<2;i++){
function foo(){alert(i);};
x[i]=foo;
}
x[0]==x[1]
---
and
---
var x=[];
for (var i=0;i<2;i++){
var foo = function(){alert(i);};
x[i]=foo;
}
x[0]==x[1]
---
The two does act differently in some browsers (meaning that
var foo = function(){}
and
function foo(){}
are not interchangable in all cases).

In Netscape 4, both give false.
In Mozilla, both give true.
In IE6 and Opera 5+, the first gives true and the second false.

All are legal, since it is at the implementation's discretion whether
to create joined objects or not.

/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Lasse Reichstein Nielsen
"Cooper" <[Email Removed]> writes:

QUOTE
Hello,
sorry for my english, but i am italian. I hope that this group understand me
and help me about a question.
I have defined a form in this mode:

[...form...]

QUOTE
CAMPO2 IS DISABLED (default)
IF CAMPO1 != 0 THEN
ENABLE CAMPO2
ELSE
DISABLE CAMPO2

I hope that my question is understood from group. thank you for people that
help me to solve this question.
Sincerly, Cooper.

Try adding this to the campo1 select tag:
<select ...
onchange="this.form.elements['campo2'].disabled=(this.selectedIndex==0)"
QUOTE

/L

--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

nad
QUOTE
Try to document.write the complete
<frameset><frame ...>...</frameset
section.

Well I document.write the whole (from <html> to </html>) and it worked !!!
Thx

Nadim Attari

J French
On Thu, 26 Jun 2003 10:26:21 -0700, "Tom Dacon" <[Email Removed]>
wrote:

QUOTE
You guys might want to take rec.woodworking out of your crosspost list for
this topic, and substitute one or more of the microsoft.public.dotnet.*
newsgroups. There's already enough offtopic bushwah here already.

Tom Dacon

While I sympathize, look at the list of posts from the original
dickhead

Newsgroups:
comp.lang.visual.basic,comp.lang.basic.visual,comp.lang.basic.visual.database,rec.woodworking,comp.lang.javascript

THAT is how you lot have been hassled.

monkeybug07
Thank you very much. I think the idea of .cssText is all I need. I
can just save and restore this property for the object. Is there any
pitfalls that I should be aware of?

Is .cssText an W3C standard?



I also have a few questions about your replies

<snip>




QUOTE

function SaveCSS(sElement) {

/* store current css properties */
adminSaveState[sElement] = document.getElementById(sElement);

Here, all you save is a reference to the DOM node.

}

In the previous code, all I am saving is a reference(pointer) to the
object? What would I need to do if I have to save a copy of the
object?



<snip>

QUOTE
I tried this:

function getCSSState(id) {
var srcStyle = document.getElementById(id).style;
var dstStyle = {};
for (var i in srcStyle) {
dstStyle[i]=srcStyle[i];
}
return dstStyle;
}

function setCSSStyle(id,srcStyle) {
var dstStyle = document.getElementById(id).style;
for (var i in dstStyle) {
dstStyle[i]=srcStyle[i]; // sets to undefined if not in srcStyle
}
for (i in srcStyle) {
if (dstStyle[i] === undefined) {
dstStyle[i]=srcStyle[i]; // sets those not in dstStyle, if any.
}
}
}

It works - kindof - in IE and Mozilla, but not in Opera. The properties
are not enumerable.


How would you call these functions? I originally declared a global
associative array to store copies of various objects. From what I see
from your functions, you are creating an associative array for a
single object? This probably ties in with my previous question.

thanks again

Dr John Stockton
JRS: In article <[Email Removed]>, seen
in news:comp.lang.javascript, Fendi Baba <[Email Removed]> posted
at Wed, 25 Jun 2003 22:04:41 :-
QUOTE
I have 3 fields in my web form. Field1, Field2, Field3 all containing
strings of dates. At any point of time, not all fields will contain
data.

What I would like to do is to set a variable which would pick up the
data from the fileds. I would only pick from one field. I would like
to do it in the following sequence -

If Field3 is not empty or "NA" then set variable = field3.value
Else
If field2 is not empty or NA then Set varaible = field2.value
Else
Variable=field1.value

I think the If else Statement will work, but I am trying to look for a
simpler code, nested If Else Statements can be difficult to maintain
and debug should there be a problem.

Maybe

Variable=field1.value
If field2 is not empty or NA then Set varaible = field2.value
If Field3 is not empty or "NA" then set variable = field3.value

It might help if you always spell 'variable' the same way, etc.


--
John Stockton, Surrey, UK. [email protected] Turnpike v4.00 MSIE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

Richard Cornford
"Lasse Reichstein Nielsen" <[Email Removed]> wrote in message
news:[Email Removed]...
<snip>
QUOTE
Try adding this to the campo1 select tag:
<select ...
onchange="this.form.elements['campo2'].disabled=
(this.selectedIndex==0)"


As a point on clean degradation; if this is for internet use, where
client-side JavaScript cannot be assumed to be available, if the
disabled attribute is set in the HTML for compo2 then the form would be
rendered unusable in the event of client side JavaScript being
disabled/unavailable.

The problem can simply be avoided by having the disabled property of
compo2 set to true by JavaScript in the onload handler for the page.
Thus, in the absence of client-side JavaScript the form remains usable.
The associated server-side process would then be responsible for
validating the form input and returning to the page for correction if
compo1's value was zero, but that level of server-side validation is
required in any case to cover the possibility that a user might
maliciously submit invalid requests.

Richard.

--

Example JavaScript DOM listings for: Opera 7.11,
Mozilla 1.2 and ICEbrowser 5.4
<URL: http://www.litotes.demon.co.uk/dom_root.html >

Richard Cornford
"Daniel" <[Email Removed]> wrote in message
news:3efac60c$0$13187$[Email Removed]...
QUOTE
This is quite clever, Richard, thank you very much!

Daniel =)

"Richard Cornford" <[Email Removed]> wrote in message
<snip inappropriately quoted material


Lasse has already asked you not to top post and to trim quoted material,
so a friendly warning; If you are unwilling to make yourself aware of,
or use, the newsgroup posting conventions, described in:-

<URL: http://jibbering.com/faq/#FAQ2_3 >

- (especially paragraph 5 and liked resources), you will find the number
and quality of responses to your posts diminishes. And if you argue
against following those conventions you will probably just find that
they diminish more rapidly.

Richard.

--

Example JavaScript DOM listings for: Opera 7.11,
Mozilla 1.2 and ICEbrowser 5.4
<URL: http://www.litotes.demon.co.uk/dom_root.html >

Cooper
"Lasse Reichstein Nielsen" <[Email Removed]> ha scritto nel messaggio
news:[Email Removed]...
QUOTE
Try adding this to the campo1 select tag:
<select ...
onchange="this.form.elements['campo2'].disabled=(this.selectedIndex==0)"

/L

Okay now work fine thanks you. Two question: 1) as i set a value from
CAMPO1 to CAMPO2 at 0 in CAMPO2 after that i have disabled it from CAMPO1 ?
About second question, i have this form:

<form name="form1" method="post" action="">
<p>Campo 1 =
<input name="campo1" type="text" value="testo">
</p>
<p>Campo 2 =
<select name="campo2" size="1">
<option value="0">0</option>
<option value="1" selected>1</option>
</select>
</p>
</form>

what i set CAMPO2 at disable only if CAMPO1 is null (empty) or contains
minimum one space? Shortly, i want that CAMPO2 is enabled only if CAMPO1
contains only ONE WORD.
Thanks you very much,
Cooper.

Daniel
QUOTE
Lasse has already asked you not to top post and to trim quoted material,
so a friendly warning; If you are unwilling to make yourself aware of,
or use, the newsgroup posting conventions, described in:-

<URL: http://jibbering.com/faq/#FAQ2_3

- (especially paragraph 5 and liked resources), you will find the number
and quality of responses to your posts diminishes. And if you argue
against following those conventions you will probably just find that
they diminish more rapidly.


I keep all posts archived on my puter, and I cannot find one where Lasse
tells me this.

Apart from that, point taken, and I'll make sure to remember to post like
this from now on =)

Daniel.

Dom Leonard
mo wrote:
QUOTE
Hi,

I have this code:

var var1 = eval(Request("Page"));
Warning: tautological use of eval

var var1 = Request("Page");
suggested.
QUOTE
Response.Write(">>"+var1);
Warning: unescaped HTML

Response.Write("&gt;&gt;"+var1);
suggested.

QUOTE
switch(var1)
{
case "Monthly":Response.Write("Monthly<BR>") %>
Error: unterminated switch statement caused by return to HTML

Move %> to after:
QUOTE
}
suggested.


<snip>
Hope it helps - you just know I havn't got ASP running :)

Dom

Dom Leonard
mc wrote:
QUOTE
Is it possible to set - up a title in the new Jscript/other window?
TIA


When writing generated content, include a TITLE tag:


var hWin=window.open("","","");
hWin.document.write("<TITLE>que?</TITLE> whatever");

(Preferably include HTML,HEAD,TITLE and BODY tags as well.]

From within a document, write a TITLE tag during load:
<html>
<head>
<script type="text/javascript">
document.write('<title>que?</title>');
</script>
....

cheers,
Dom

David Ron
"Fred Serry" <[Email Removed]> wrote in message news:<bdec17$rrkjj$[Email Removed]>...
QUOTE
"David Ron" <[Email Removed]> schreef in bericht
news:[Email Removed]...
The following code works in Mozilla 1.3 and Netscape 7, but not it IE
6.  Am I missing some browser compatibility somewhere?

Thanks for any help you can give me.

--TwinkieStix


<td class='productPageItemPriceTD'
name='productPagePriceTD'>$29.95</td


Hi,

AFAIK 'name' is not a valid attribute for a table detail. I added an id,
then it worked.

<td class='productPageItemPriceTD' id='productPagePriceTD'
name='productPagePriceTD'>$29.95</td


Fred


Your right, it does in IE and Mozilla. Is it proper to assume that
getElementsByName() works wih ID's on a page as well as names on a
page? Is this a W3C standard or does it just happen to work on the
two browsers?

Thanks,
David Ron

Doug Miller
In article <[Email Removed]>, [Email Removed]_.bin wrote:
QUOTE
On Thu, 26 Jun 2003 09:49:22 +0200, "Laurent Bugnion, GalaSoft"
<galasoft-LB@bluewin_NO_SPAM.ch> wrote:

<snip

First of all, C#'s syntax is based on the C-syntax, which is more modern
and simply makes more sense.
<snip

The 'C' syntax is designed for the convenience of the compiler writer

Please trim rec.woodworking from your followups. Thank you.

--
Regards,
Doug Miller (alphageek-at-milmac-dot-com)

Save the baby humans - stop partial-birth abortion NOW

Tom Dacon
You guys might want to take rec.woodworking out of your crosspost list for
this topic, and substitute one or more of the microsoft.public.dotnet.*
newsgroups. There's already enough offtopic bushwah here already.

Tom Dacon

"J French" <[Email Removed]_.bin> wrote in message
news:[Email Removed]...
QUOTE
On Thu, 26 Jun 2003 09:49:22 +0200, "Laurent Bugnion, GalaSoft"
<galasoft-LB@bluewin_NO_SPAM.ch> wrote:

<snip

First of all, C#'s syntax is based on the C-syntax, which is more modern
and simply makes more sense.
<snip

The 'C' syntax is designed for the convenience of the compiler writer


Lasse Reichstein Nielsen
"Cooper" <[Email Removed]> writes:

QUOTE
"Lasse Reichstein Nielsen" <[Email Removed]> ha scritto nel messaggio
news:[Email Removed]...
Try adding this to the campo1 select tag:
<select ...
onchange="this.form.elements['campo2'].disabled=(this.selectedIndex==0)"

/L

Okay now work fine thanks you.  Two question: 1) as i set a value from
CAMPO1 to CAMPO2 at 0 in CAMPO2 after that i have disabled it from CAMPO1 ?

This begins to get larger, so let's move it into a function.

<script type="text/javascript">
function setCamp2(camp1) {
var camp2 = camp1.form.elements['camp2']
var disableCamp2 = false;
if (camp1.selectedIndex == 0) {
disableCamp2 = true;
camp2.selectedIndex = 0;
}
camp2.disabled = disableCamp2;
}
</script>

and again
<select name="camp1" ... onchange="setCamp2(this);">

QUOTE
About second question, i have this form:

<form name="form1" method="post" action=""
<p>Campo 1 =
<input name="campo1" type="text" value="testo"
</p
<p>Campo 2 =
<select name="campo2" size="1"
<option value="0">0</option
<option value="1" selected>1</option
</select
</p
</form

what i set CAMPO2 at disable only if CAMPO1 is null (empty) or contains
minimum one space? Shortly, i want that CAMPO2 is enabled only if CAMPO1
contains only ONE WORD.

let's try another function, all we need to do is to change
the condition of the if-statement:

<script type="text/javascript">
function setCamp2(camp1) {
var camp2 = camp1.form.elements['camp2']
var disableCamp2 = false;
if (camp1.value.length == 0 ||
camp1.value.indexOf(" ") != -1) { // "" or "... ..."
disableCamp2 = true;
camp2.selectedIndex = 0;
}
camp2.disabled = disableCamp2;
}
</script>

and

<input type="text" name="camp1" onchange="setCamp2(this)">


/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Doug Miller
In article <[Email Removed]>, [Email Removed]_.bin wrote:
QUOTE
On Thu, 26 Jun 2003 10:26:21 -0700, "Tom Dacon" <[Email Removed]
wrote:

You guys might want to take rec.woodworking out of your crosspost list for
this topic, and substitute one or more of the microsoft.public.dotnet.*
newsgroups. There's already enough offtopic bushwah here already.

Tom Dacon

While I sympathize, look at the list of posts from the original
dickhead

Newsgroups:
comp.lang.visual.basic,comp.lang.basic.visual,comp.lang.basic.visual.database,r
ec.woodworking,comp.lang.javascript

THAT is how you lot have been hassled.


We understand perfectly well how it all got started. What many of us here have
trouble understanding is why you guys *continue* to cross-post into
rec.woodworking, despite repeated requests that you stop, long after the
trolls have left.

--
Regards,
Doug Miller (alphageek-at-milmac-dot-com)

Save the baby humans - stop partial-birth abortion NOW

Lasse Reichstein Nielsen
Dr John Stockton <[Email Removed]> writes:

QUOTE
For appreciably shorter code to give a somewhat similar display, see
<URL:http://www.merlyn.demon.co.uk/js-date6.htm#DP>.

While the calendar itself works, there is a problem with the Show button
at the foot of the page; the code of the function InitCalendar is
displayed incorrectly.  Is a fix obvious to any expert?

You are embedding the InitCalendar.toString() result directly into
the generated HTML. That means that the "<input type=button ..."
is treated as HTML.

You can change
InitCalendar.toString(),
to
InitCalendar.toString().replace(/</g,'&amp;lt;'),

For more safety, you could also change ">" and "&" into entities,
but apparently, none occur in the code of this or the other functions.

/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Janwillem Borleffs
"Paul" <[Email Removed]> schreef in bericht
news:[Email Removed]...
QUOTE
Hi,


I have the following script which I need to tweak. The script (see end
of message) will open a popup window which expands to a certain size.
When the window is expanded the maximize button is greyed out - I'd
like to be able to resize it if I wish. I've tried ammending the line
'win2=window.open("","","scrollbars")' to
win2=window.open("","","scrollbars=yes,resizeable=yes")' but to no
avail. Any help would be appreciated. If anybody has a different
script that produces the same effect I'd also be interested in it.


It's not 'resizeable' but 'resizable':

win2=window.open("","","scrollbars=yes,resizable=yes")


JW

Vjeko
In IE6,0 under Windows this code sample works well when the script is placed
in the BODY section. And when it is in the HEAD, it doesnt work. I think
that is because the browser does not rendering HTML page in HEAD section
(unless you have document.write).


"David" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
I am new to javascript (learned yesterday), am working on a mac, and
using internet explorer 5.1 for macs to preview web page.
this simple array and for loop works fine:

var color = new Array("red","green","purple");
for (var i=0; i<color.length; i++)
{
document.writeln ("it works<br>");
document.bgColor= color[i];
alert ("continue?");
}
however, when the first line of the loop is removed, the page displays
the alert, but not the new background color:

var color = new Array("red","green","purple");
for (var i=0; i<color.length; i++)
{

document.bgColor= color[i];
alert ("continue?");
}

I am sure there is a simple explanation, thanks for any help.
David


Alex Fitzpatrick
Laurent Bugnion, GalaSoft wrote:
QUOTE
Hi,

Dirty Sanchez wrote:

It's OK, I've resolved the problem, it was because I wasn't using a
Dell mouse mat.


You can use other mouse mats, but you should make sure that your mouse
mat's driver is up-to-date.

I wrote my own... in JavaScript!

--
Alex

Cooper
"Lasse Reichstein Nielsen" <[Email Removed]> ha scritto nel messaggio
news:[Email Removed]...
QUOTE
Okay now work fine thanks you.  Two question: 1) as i set a value from
CAMPO1 to CAMPO2 at 0 in CAMPO2 after that i have disabled it from
CAMPO1 ?

This begins to get larger, so let's move it into a function.


Work thanks :) latest question, i have this form:

<form name="form1" method="post" action="">
Campo 1=
<select name="campo1" size="1" id="campo1">
<option value="O" selected>Option1</option>
<option value="1">Option2</option>
</select>
<select name="canpo1a" size="1" id="campo1a">
<option value="0" selected>0</option>
</select>
</form>

and this select:

<select name="campo1b" size="1" id="campo1b">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

I want that from CAMPO1 i select OPTION1 display CAMPO1A and if i select
OPTION2 display CAMPO1B. Shortly, second select list depend from first
select list.
As solve it?
Thanks you very much for help me.
Cooper.

Cooper
"Lasse Reichstein Nielsen" <[Email Removed]> ha scritto nel messaggio
news:[Email Removed]...
QUOTE

Not work, about your code, i have now (complete code):


<html>
<body onload="setVisible(document.forms['form1'].elements['campo1'])">
<form name="form1" method="post" action="">
<p>Campo 1 =
<select name="campo1" size="1" id="campo1" onchange="setVisibile(this)">
<option value="O" selected>Option1</option>
<option value="1">Option2</option>
</select>
</p>
<p>Campo 1a =
<select name="campo1a" size="1" id="campo1a">
<option value="0" selected>0</option>
</select>
Campo 1b =
<select name="campo1b" size="1" id="campo1b"
onchange="setVisibile(this)">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
</form>
</body>
</html>

But not work, i display select CAMPO1 and the select: CAMPO1A and CAMPO1B.
Where is my error?
Cooper.

Cooper
"Lasse Reichstein Nielsen" <[Email Removed]> ha scritto nel messaggio
news:[Email Removed]...
QUOTE

Not work, about your code, i have now (complete code):


<html>
<body onload="setVisible(document.forms['form1'].elements['campo1'])">
<form name="form1" method="post" action="">
<p>Campo 1 =
<select name="campo1" size="1" id="campo1" onchange="setVisibile(this)">
<option value="O" selected>Option1</option>
<option value="1">Option2</option>
</select>
</p>
<p>Campo 1a =
<select name="campo1a" size="1" id="campo1a">
<option value="0" selected>0</option>
</select>
Campo 1b =
<select name="campo1b" size="1" id="campo1b">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
</form>
</body>
</html>

But not work, i display select CAMPO1 and the select: CAMPO1A and CAMPO1B.
Where is my error?
Cooper.

Vjekoslav Begovic
Something like this:

<html>
<head>
<script language="JavaScript">
function copyIt(from, where){
var fromCtl = document.getElementById(from);
var toCtl = document.getElementById(where);
fromCtl.focus();
var tempText = document.selection.createRange().text;
toCtl.value = tempText;
}
</script>
</head>

<body>
<textarea cols="" rows="" id="area_1"></textarea>
<textarea cols="" rows="" id="area_2"></textarea>
<input type="Button" value="Copy" onclick="copyIt('area_1', 'area_2')">
</body>
</html>

"Serkan Ceylani" <[Email Removed]> wrote in message
news:AhjKa.50$[Email Removed]...
QUOTE
How can I copy selected (all or some doesn't matter) Text from one HTML
textarea and paste it to another one using javascript?

Thanks in Advance,



Martin Honnen
Urs Gubler wrote:
QUOTE
I have a very simple problem, nevertheless it seems nobody had it so far !
After working full 5 days on it without a solution I try the Google Forum

I have 2 HTML Pages.
Page2 is a PopUp from Page1.

I have no problem to acces fields from Page1 in Page2 with:

CellValue = this.opener.document.getElementById("IdDate").value;
alert(CellValue);

unless the Id referenced to a Cell in a Table such as <TD
ID=Cell1>Hello</TD
In this case

CellValue = this.opener.document.getElementById("Cell1").value;
alert(CellValue);

Returns the Value Undefined (in the alert box) and not "Hello".

Is this a bug or am I wrong ?

Well, <td> elements don't have a value. I guess it is easiest to use
document.getElementById('Cell1').innerHTML
to access what you regard as the "value" of the cell. In some cases this
might not work as intended, if the cell has child elements then you have
to use
innerText
with IE and Opera and you could create a range and use to string with
Mozilla.



--

Martin Honnen
http://JavaScript.FAQTs.com/

urs gubler
Martin,

This I call an instant reply.
It works !!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks a lot, this is realy great.
It has no value, this is true.

In German we say:

G: Kaum macht man was richtig schon klappts !
E: As soon as you do something rigth it works !

Thanks a lot and regards.

Urs


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Ken Kast
Thanks for your good ideas. I will try them out.

Ken
"Ken Kast" <[Email Removed]> wrote in message
news:hWPJa.41172$[Email Removed]...
QUOTE
I have a script that creates an IMG tag, myIMG.  I have a function f (x).
I
want the click handler to be f(a) where a is a specific value.  If the tag
was in HTML I would use onclick="f(a);".  In script, if I wanted f() to be
my handler, I'd use myIMG.onclick=f.  I know I could create myHandler h()
{ f(a); } and use myIMG.onclick = myHandler.  The thing is, I want the
choice of f to be determined by the factors that go into creating myIMG.
In
other words, f and its arguments are both"variables."

Can anyone give me an idea how to create this flexible handler?

Thanks.

Ken



Michael Stemper
In article <3ef969f7$0$5429$[Email Removed]>, "Mike" <[Email Removed]> writes:

QUOTE
Please can you help ?:

Glad to.

QUOTE
<script language="JavaScript" type="text/JavaScript"
function closecheck ()"

First error: unterminated string constant. Get rid of the " at the
end of the line.

QUOTE
{
if (page2.htm !== true)

Second error: the test for inequality is != not !==
Third error: you should test for something being equal or not equal
to true, you should just test it directly.

QUOTE
window.close ()
}

Fourth error: your function just ended here - check the matching {}.

--
Michael F. Stemper
#include <Standard_Disclaimer>
Visualize whirled peas!

David
Martin,
Thanks very much it worked a treat.
David

Lasse Reichstein Nielsen
Dr John Stockton <[Email Removed]> writes:

QUOTE
On the subject of dates, I have perceived a little-known feature which
can in fact cause error in operation.  In, at least, my MSIE 4,

new Date('2003/04/05 06:07p')

is accepted; but now p is not short for /post meridiem/, but represents
the military P time zone, which contains Moscow (P = Putin).  A
represents the Azores zone, Z represents GMT (Zulu time, which the true
Zulus do not normally use), and all the other letters have corresponding
meanings except for J, which yields NaN.

Since Microsoft just received 471 million dollar order from the US Army,
I guess it won't be changed any time soon :).

(Military timezones by letter:
<URL:http://greenwichmeantime.com/info/timezone.htm>
They only needed 25, but I have no idea why it was "J" they left out.
Probably because it is too close to "I")

/L 'Living in Bravo times!'
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Lasse Reichstein Nielsen
Timo Steinbach <[Email Removed]> writes:

QUOTE
if(document.Formular.00KUGH23897523952358.value == "")  {

The two first characters are zeros, not the letter O. Using the
dot-notation for object property access requires that the property
name is a single legal identifier, so it must start with a letter or
an underscore.

QUOTE
Difference is the name of the Textfield. Maybe it's too long. Or it's
not to be allowed to start with a number.

It is not allowed to start with a digit.

QUOTE
Does anybody know how I can code it to work?
if(document.Formular."00KUGH23897523952358".value == "") -> doesn't work
if(document.Formular.'00KUGH23897523952358'.value == "") -> doesn't work

When you know that the roperty name is illegal, the problem matches
this FAQ entry: <URL:http://jibbering.com/faq/#FAQ4_25>

That is:
if (document.Formular["00KUGH23897523952358"].value ...

I would even recommend writing it as

document.forms["Formular"].elements["00KUGH23897523952358"].value

Sometimes it is not needed, but in cases like this, where it is, its
a habit that saves a lot of trouble.

/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Evertjan.
Timo Steinbach wrote on 27 jun 2003 in comp.lang.javascript:

QUOTE
Difference is the name of the Textfield. Maybe it's too long. Or it's
not to be allowed to start with a number.

Test it out, as I do below.

QUOTE
Does anybody know how I can code it to work?
if(document.Formular."00KUGH23897523952358".value == "") -> doesn't work
if(document.Formular.'00KUGH23897523952358'.value == "") -> doesn't work

This works:

<form name='Formular'>
<input name='00KUGH23897523952358' value='Hi'>
</form>
<script>
alert(document.Formular['00KUGH23897523952358'].value)
</script>

see:
<http://www.litotes.demon.co.uk/js_info/sq_brackets.html>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Tom Dacon
J, I didn't see the original post from the original dickhead. My newsreader
picked up the thread about three posts above yours, so I figured it didn't
make much difference where I threw my two cents worth in. I understand that
you're not the guy who started this.

Tom Dacon

"J French" <[Email Removed]_.bin> wrote in message
news:[Email Removed]...
QUOTE
On Thu, 26 Jun 2003 10:26:21 -0700, "Tom Dacon" <[Email Removed]
wrote:

You guys might want to take rec.woodworking out of your crosspost list
for
this topic, and substitute one or more of the microsoft.public.dotnet.*
newsgroups. There's already enough offtopic bushwah here already.

Tom Dacon

While I sympathize, look at the list of posts from the original
dickhead

Newsgroups:

comp.lang.visual.basic,comp.lang.basic.visual,comp.lang.basic.visual.databas

e,rec.woodworking,comp.lang.javascript
QUOTE

THAT is how you lot have been hassled.



Doug Miller
In article <[Email Removed]>, "Tom Dacon" <[Email Removed]>
wrote:

[another irrelevant crosspost snipped]

PLEASE stop cross-posting into rec.woodworking !

Serkan Ceylani
Thank you very much...
Serkan


Vjekoslav Begovic wrote:
QUOTE
Something like this:

<html
<head
<script language="JavaScript"
function copyIt(from, where){
var fromCtl = document.getElementById(from);
var toCtl = document.getElementById(where);
fromCtl.focus();
var tempText = document.selection.createRange().text;
toCtl.value = tempText;
}
</script
</head

<body
<textarea cols="" rows="" id="area_1"></textarea
<textarea cols="" rows="" id="area_2"></textarea
<input type="Button" value="Copy" onclick="copyIt('area_1', 'area_2')"
</body
</html

"Serkan Ceylani" <[Email Removed]> wrote in message
news:AhjKa.50$[Email Removed]...

How can I copy selected (all or some doesn't matter) Text from one HTML
textarea and paste it to another one using javascript?

Thanks in Advance,






Mark
You never asign "a" a value so when you say a++ - it doesn't know what
number to increase by one.

Matt


"Mike" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
can u tell me whats wrong with this and how to correctly make it work?

<html
<head
<title>Untitled Document</title
<SCRIPT LANGUAGE="JavaScript"
function too_many() {
for (var j = 1; j <= 6; j++) {
box = eval("document.checkboxform.C" + j);
var a;
if (box.checked == true) a++;
if (a > 3) alert('Article '+a+' has been emailed to you.');
}
}
</SCRIPT
</head

<body
<form name=checkboxform
<input type=checkbox name="C1" onClick="too_many()">C1<br
<input type=checkbox name="C2" onClick="too_many()">C2<br
<input type=checkbox name="C3" onClick="too_many()">C3<br
<input type=checkbox name="C4" onClick="too_many()">C4<br
<input type=checkbox name="C5" onClick="too_many()">C5<br
<input type=checkbox name="C6" onClick="too_many()">C6<br
</form
</body
</html



Mike
lol, it always is the simplist things :) okay not always.. thanks matt
"Mark" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
You never asign "a" a value so when you say a++ - it doesn't know what
number to increase by one.

Matt


"Mike" <[Email Removed]> wrote in message
news:[Email Removed]...
can u tell me whats wrong with this and how to correctly make it work?

<html
<head
<title>Untitled Document</title
<SCRIPT LANGUAGE="JavaScript"
function too_many() {
for (var j = 1; j <= 6; j++) {
box = eval("document.checkboxform.C" + j);
var a;
if (box.checked == true) a++;
if (a > 3) alert('Article '+a+' has been emailed to you.');
}
}
</SCRIPT
</head

<body
<form name=checkboxform
<input type=checkbox name="C1" onClick="too_many()">C1<br
<input type=checkbox name="C2" onClick="too_many()">C2<br
<input type=checkbox name="C3" onClick="too_many()">C3<br
<input type=checkbox name="C4" onClick="too_many()">C4<br
<input type=checkbox name="C5" onClick="too_many()">C5<br
<input type=checkbox name="C6" onClick="too_many()">C6<br
</form
</body
</html





Lasse Reichstein Nielsen
"Mike" <[Email Removed]> writes:

QUOTE
can u tell me whats wrong with this and how to correctly make it work?

It helps if you tell us what it is supposed to do. I'll try, but not being
psychic, I can't guarantee that the result is what you want.

QUOTE
<html
<head
<title>Untitled Document</title
<SCRIPT LANGUAGE="JavaScript"

Should be
<script type="text/javascript">
In HTML 4, the type attribute is mandatory and the language attribute
is deprecated.

QUOTE
function too_many() {

It is necessary to initialize the a variable.

var a=0;

(this was mist likely the bug that kept the script from working)

QUOTE
for (var j = 1; j <= 6; j++) {
box = eval("document.checkboxform.C" + j);

You probably never need to use eval.

box = document.forms["checkboxform"].elements["C"+j];

is much more efficient.

QUOTE
var a;
if (box.checked == true) a++;

if (box.checked) a++;

is equivalent and shorter.

QUOTE
if (a > 3) alert('Article '+a+' has been emailed to you.');

You might want to move this line outside the for loop.

/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

Richard Cornford
"Mark" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
You never asign "a" a value so when you say a++ - it
doesn't know what number to increase by one.
<snip


Technically I think it knows exactly which number to increment, but that
number is NaN and NaN + 1 == NaN.

Richard.

Timo Steinbach
QUOTE
if (document.Formular["00KUGH23897523952358"].value ...

document.forms["Formular"].elements["00KUGH23897523952358"].value

Thats great. It's working fine, now.
Thank you.

Richard Cornford
"Lasse Reichstein Nielsen" <[Email Removed]> wrote in message
news:[Email Removed]...
<snip>
QUOTE
Joining of functions (which I hadn't read in detail
before) is actually interesting.

Compare
---
var x=[];
for (var i=0;i<2;i++){
function foo(){alert(i);};
x[i]=foo;
}
x[0]==x[1]
---
and
---
var x=[];
for (var i=0;i<2;i++){
var foo = function(){alert(i);};
x[i]=foo;
}
x[0]==x[1]
---
The two does act differently in some browsers
(meaning that
var foo = function(){}
and
function foo(){}
are not interchangable in all cases).

In Netscape 4, both give false.
In Mozilla, both give true.
In IE6 and Opera 5+, the first gives true and the second false.

I was interested in your results from these tests but I was unable to
reproduce them, particularly your results for Gecko browsers. The
following are my test functions and results:-

function funcTest1(){
var x=[];
for (var i=0;i<2;i++){
function foo(){alert(i);};
x[i] = foo;
}
return (x[0]==x[1]);
}

An inner function declaration within the - for - loop.
Mozilla 1.0, 1.2, 1.3, Netscape 7.02 and K-Meleon 0.7 (Gecko browsers)
== false
Opera 6.05 & 7.11and IE 6 == true
Netscape 4.79 == false


function funcTest3(){
var x=[];
for (var i=0;i<2;i++){
x[i] = function(){alert(i);};
}
return (x[0]==x[1]);
}

An inner function expression within the - for - loop. I would not
expect this to be considered to be the same function on each iteration
of the loop.
Mozilla 1.0, 1.2, 1.3, Netscape 7.02 and K-Meleon 0.7 (Gecko browsers)
== false
Opera 6.05 & 7.11and IE 6 == false
Netscape 4.79 == false


function funcTest5(){
var x=[];
function foo(){alert(i);};
for (var i=0;i<2;i++){
x[i] = foo;
}
return (x[0]==x[1]);
}

An inner function declaration outside of the - for - loop. This I was
expecting to always be considered as the same function (ECMA 262 section
10.1.3).
Mozilla 1.0, 1.2, 1.3, Netscape 7.02 and K-Meleon 0.7 (Gecko browsers)
== true
Opera 6.05 & 7.11and IE 6 == true
Netscape 4.79 == true

There seems to be a discrepancy in the interpretation of the first
function. The inner function declaration looks like it might be being
interpreted as a function expression with optional identifier by Net 4
and Gecko browsers, but even then the results do not conform with my
interpretation of ECMA section 10.1.3 and 13.

I did repeat these test replacing - alert(i); - with - alert("m"); - to
see if the inner function's use of a local variable from it's containing
function was influencing the results. However, that set of tests
produced exactly the same results as above.

QUOTE
All are legal, since it is at the implementation's discretion
whether to create joined objects or not.

I also performed an additional test to gauge the extent to which
function objects would be joined or reused. Following the examples in
the footnote to ECMA 262 section 13.2:-

function getFoo(){
function foo(){alert('m');};
return foo;
}
function funcTest9(){
var x=[];
for (var i=0;i<2;i++){
x[i] = getFoo();
}
return (x[0]==x[1]);
}

- all of the browsers used for the previous test returned false from -
funcTest9 -.

As the - foo - function returned from each call to - getFoo - should be
"indistinguishable" from one and other -

<quote cite="ECMA 262 section 13.2">
.. . . the differences between their [[Scope]] properties are not
observable, . . .
</quote>

- I would have to conclude that none of these browsers have chosen to
implement the optional optimisation mentioned in ECMA 262 section 13.2
(and 13.1.2) and that no joining of function objects is going on.

Having apparently ascertained that any inner function returned by a
function will be a unique function object and that function expressions
produce unique function objects I think that this has implications for
how inner functions should be used. For example:-

function MyObject(x){
this.x = x;
this.getX = function(){
return this.x
};
}

- will create a new function object for each MyObject created, while:-

function MyObject(x){
this.x = x;
}
MyObject.prototype.getX = function(){
return this.x
}

- should share the same function object between all instances of
MyObject.

The same would go for assigning an event handler with an inner function
expression. One function object for each invocation of the outer
function. While defining the handler function externally and assigning
it by reference would allow the same function object to be shared by
many event handlers.

If the browsers cannot or will not recognise when two functions are
indistinguishable and optimise their use the onus falls on the script
author to do so. Saving memory consumption and improving execution speed
(as less new function objects need to be created).

Leaving inner functions to be used only when their special
characteristics confer some advantage, when they actually are accessing
properties of their outer functions and/or resulting closures. (Or maybe
in code that will only be executed once.)

Richard.

Lasse Reichstein Nielsen
"Richard Cornford" <[Email Removed]> writes:

QUOTE
I was interested in your results from these tests but I was unable to
reproduce them, particularly your results for Gecko browsers.

It seems the context is important too. I evaluated the expressions
using eval (in my test page:
<URL:http://www.infimum.dk/HTML/javascript/jstest4.html>)
That means that the code was part of an eval block, not a function
body.

QUOTE
The following are my test functions and results:-

function funcTest1(){
var x=[];
for (var i=0;i<2;i++){
function foo(){alert(i);};
x[i] = foo;
}
return (x[0]==x[1]);
}
An inner function declaration within the - for - loop.
Mozilla 1.0, 1.2, 1.3, Netscape 7.02 and K-Meleon 0.7 (Gecko browsers)
== false
Opera 6.05 & 7.11and IE 6 == true
Netscape 4.79 == false

....
QUOTE
There seems to be a discrepancy in the interpretation of the first
function. The inner function declaration looks like it might be being
interpreted as a function expression with optional identifier by Net 4
and Gecko browsers, but even then the results do not conform with my
interpretation of ECMA section 10.1.3 and 13.

Indeed, it couldn't be a function expression with identifier, since
that would not declare a "foo" variable in the surroundings, and "foo"
has been declared in the next line.

I do think this is in accordance with ECMA262 section 13.2, and what
we are seeing from IE and Opera *is* the joining of the functions.

QUOTE
I also performed an additional test to gauge the extent to which
function objects would be joined or reused. Following the examples in
the footnote to ECMA 262 section 13.2:-
....
- I would have to conclude that none of these browsers have chosen to
implement the optional optimisation mentioned in ECMA 262 section 13.2
(and 13.1.2) and that no joining of function objects is going on.

It is a possible optimization that is requries some testing (although
not a lot). I can understand why they haven't prioritized it (yet, I
hope).

QUOTE
Having apparently ascertained that any inner function returned by a
function will be a unique function object and that function expressions
produce unique function objects I think that this has implications for
how inner functions should be used.
....

Good points, if execution speed and memory are the primary goals.

However, I am weary at designing programs for such a diverse and
evolving platform as browsers' Javascript by aiming at the artifacts
of the current impementations. I would much prefer to program for ease
of maintaining, and only optimize when the need for speed is dire.

/L
--
Lasse Reichstein Nielsen - [Email Removed]
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

D to the O to the M
Thanks Paul, I'll give that a go.

Richard Cornford
"Lasse Reichstein Nielsen" <[Email Removed]> wrote in message
news:[Email Removed]...

QUOTE
I was interested in your results from these tests but I was unable
to reproduce them, particularly your results for Gecko browsers.

It seems the context is important too. I evaluated the
expressions using eval (in my test page:
<URL:http://www.infimum.dk/HTML/javascript/jstest4.html>)
That means that the code was part of an eval block, not
a function body.

I will look at that page later. Now I am also going to have to reread
the ECMA Script sections on eval code and see how expected your results
were in that context.

<snip>
QUOTE
... The inner function declaration looks like it might be being
interpreted as a function expression with optional identifier
by Net 4 and Gecko browsers, but even then the results do not
conform with my interpretation of ECMA section 10.1.3 and 13.

Indeed, it couldn't be a function expression with identifier,
since that would not declare a "foo" variable in the surroundings,
and "foo" has been declared in the next line.

Exactly my reason for rejecting that hypothesis.

QUOTE
I do think this is in accordance with ECMA262 section 13.2, and
what we are seeing from IE and Opera *is* the joining of the
functions.

My reading of section 10.1.3 would suggest that, recognising the
function declaration as such, IE and Opera are adding a named reference
to one unique function object to the variable object and just
disregarding the fact that the declaration appears in a - for - loop, so
there is only one function object and no joining is taking place. (and
the function is not re-declared in each iteration of the loop).

My belief is encouraged by this test:-

function funcTest10(){
while(false){
function foo(){alert(i);};
}
return foo;
}
alert(funcTest10());

Where Opera and IE alert the toString version of foo and Gecko browsers
produce a JavaScript error - foo is undefined - on the - return foo; -
line.

I think it is the Gecko browsers that are off spec here (Netscape 4 can
be excused for historical reasons).

In any event, if Opera and IE were joining the functions in the previous
example why would they not implement the joining in the case that
followed the example specifically targeted for optimisation in ECMA 262
section 13.2?

<snip>
QUOTE
...
Good points, if execution speed and memory are the primary
goals.

Speed an efficiency are personal obsessions. That probably stems form my
learning 68000 assembly language in the early 1990s. When you are
gauging code by the clock-cycle you get a good feeling for what is fast
and what isn't. I haven't been able to shake the impression that if code
can be faster it probably should be. I doubt that I will, it is part of
the "craft".

But JavaScript is inevitably relatively slow. Take the recent thread on
vector graphics; the library that Jim referenced uses a lot of the fast
algorithms that I implemented in assembly language for 3D vector
graphics on 8Mhz CPUs, but on a 100 times faster computer they are still
nowhere near fast enough to do 3D vector animation in a web browsers
(even the relatively crude stuff from the early 90s (though I might yet
see if I can do better)).

Memory doesn't seem that important on a desktop computer, with a 32 bit
Windows system having a 2Gb (or is it 4, I forget) memory map and using
a swap file to fake any that is not physically present. But what about
PDAs? The browser and the DOM representation take up a lot of the
available memory and don't leave that much for JavaScript to work in.

QUOTE
However, I am weary at designing programs for such a diverse
and evolving platform as browsers' Javascript by aiming at
the artifacts of the current impementations. I would much
prefer to program for ease of maintaining, and only optimize
when the need for speed is dire.

I don't think that the approach that I was recommending would
necessarily compromise maintenance. Assigning public methods to a
prototype is virtually self-documenting and assigning externally defined
method to event handlers should be clear enough if they are well named
and commented.

Richard.

Vladdy
"isaac" <[Email Removed]> wrote in message
news:[Email Removed]...
| hi all
| is there a way in javascript to make a request to a server in response
| to an event but not reload the page? that's not very clear, is it.
| for example, could i simply feed server supplied text or html to a
| textbox or inline frame without reloading the entire page? the text
| or embeded html or whatever would come from a php script, when a user
| clicked a button or an image or something. i realize i'm being hazy,
| but i'm flexible as to the implementation. i've been playing with php
| and i'd like to work on a chat script, but i don't know how to handle
| the client side. i've skimmed through the javascript reference on the
| netscape site, but if someone could give me a hint or two as to which
| functions/objects/methods i should be looking at it'd be a big help.
|
| thanks in advance,
| hunwalla

Read this:
http://www.codingforums.com/showthread.php?s=&threadid=16205

Vladdy


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.