[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Modular code, HTML, HTML5 and JS

JT

5/17/2016 8:20:00 AM

I decided to try write abit more modular code, but i have no real good example of how to do it.

Lets say i have index.html and main.js, i do have figured out how to call main.js from index.html.

But what i would like to know is how do i refer a form with a textfiel within index.html?
Do the script know in which document the refered form reside?

In HTML pages with inline/embedded javascript, i know one do it like this.

document.myform.mytext.value = somedata;

I never quite understood what document refer to in this case.
I do have a memory passing data between frames, but never done it between a js and html file.

Is it enough just refer to the form like above?
28 Answers

JT

5/17/2016 8:44:00 AM

0

Den tisdag 17 maj 2016 kl. 10:19:37 UTC+2 skrev jonas.t...@gmail.com:
> I decided to try write abit more modular code, but i have no real good example of how to do it.
>
> Lets say i have index.html and main.js, i do have figured out how to call main.js from index.html.
>
> But what i would like to know is how do i refer a form with a textfiel within index.html?
> Do the script know in which document the refered form reside?
>
> In HTML pages with inline/embedded javascript, i know one do it like this.
>
> document.myform.mytext.value = somedata;
>
> I never quite understood what document refer to in this case.
> I do have a memory passing data between frames, but never done it between a js and html file.
>
> Is it enough just refer to the form like above?

It worked, but how to have each function reside within individual files is it just by listing the src within index.html?

<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>

And so on? will the functions within one and two be reachable from main without further refereces?

JT

5/17/2016 8:50:00 AM

0

Den tisdag 17 maj 2016 kl. 10:44:12 UTC+2 skrev jonas.t...@gmail.com:
> Den tisdag 17 maj 2016 kl. 10:19:37 UTC+2 skrev jonas.t...@gmail.com:
> > I decided to try write abit more modular code, but i have no real good example of how to do it.
> >
> > Lets say i have index.html and main.js, i do have figured out how to call main.js from index.html.
> >
> > But what i would like to know is how do i refer a form with a textfiel within index.html?
> > Do the script know in which document the refered form reside?
> >
> > In HTML pages with inline/embedded javascript, i know one do it like this.
> >
> > document.myform.mytext.value = somedata;
> >
> > I never quite understood what document refer to in this case.
> > I do have a memory passing data between frames, but never done it between a js and html file.
> >
> > Is it enough just refer to the form like above?
>
> It worked, but how to have each function reside within individual files is it just by listing the src within index.html?
>
> <script type="text/javascript" src="main.js"></script>
> <script type="text/javascript" src="one.js"></script>
> <script type="text/javascript" src="two.js"></script>
>
> And so on? will the functions within one and two be reachable from main without further refereces?

It worked, what is the penalty timewise to have the functions reside each within one file? Is it just the load time of script that change?

Tim Streater

5/17/2016 9:18:00 AM

0

In article <ec9a7a6b-b3af-4d83-9b28-e9fff5c24f4b@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:

>I decided to try write abit more modular code, but i have no real good example
>of how to do it.
>
>Lets say i have index.html and main.js, i do have figured out how to call
>main.js from index.html.
>
>But what i would like to know is how do i refer a form with a textfiel within
>index.html?
>Do the script know in which document the refered form reside?
>
>In HTML pages with inline/embedded javascript, i know one do it like this.
>
>document.myform.mytext.value = somedata;
>
>I never quite understood what document refer to in this case.
>I do have a memory passing data between frames, but never done it between a js
>and html file.

Why don't you buy a good book on html, another good book on javascript,
and READ THEM.

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens

Wally W.

5/17/2016 12:36:00 PM

0

On Tue, 17 May 2016 10:17:52 +0100, Tim Streater wrote:

>In article <ec9a7a6b-b3af-4d83-9b28-e9fff5c24f4b@googlegroups.com>,
><jonas.thornvall@gmail.com> wrote:
>
>>I decided to try write abit more modular code, but i have no real good example
>>of how to do it.
>>
>>Lets say i have index.html and main.js, i do have figured out how to call
>>main.js from index.html.
>>
>>But what i would like to know is how do i refer a form with a textfiel within
>>index.html?
>>Do the script know in which document the refered form reside?
>>
>>In HTML pages with inline/embedded javascript, i know one do it like this.
>>
>>document.myform.mytext.value = somedata;
>>
>>I never quite understood what document refer to in this case.
>>I do have a memory passing data between frames, but never done it between a js
>>and html file.
>
>Why don't you buy a good book on html, another good book on javascript,
>and READ THEM.

Better yet, buy a book on PHP and don't bother visitors with running
javascript for basic functionality

Javascript is turned off in my default browser.

I might fire up a different browser for *your* site, but I will
probably look first for a site that has a better design. If I find
one, I will go there instead.

Aleksandro

5/18/2016 12:30:00 AM

0

On 17/05/16 08:36, Wally W. wrote:
> On Tue, 17 May 2016 10:17:52 +0100, Tim Streater wrote:
>
>> In article <ec9a7a6b-b3af-4d83-9b28-e9fff5c24f4b@googlegroups.com>,
>> <jonas.thornvall@gmail.com> wrote:
>>
>>> I decided to try write abit more modular code, but i have no real good example
>>> of how to do it.
>>>
>>> Lets say i have index.html and main.js, i do have figured out how to call
>>> main.js from index.html.
>>>
>>> But what i would like to know is how do i refer a form with a textfiel within
>>> index.html?
>>> Do the script know in which document the refered form reside?
>>>
>>> In HTML pages with inline/embedded javascript, i know one do it like this.
>>>
>>> document.myform.mytext.value = somedata;
>>>
>>> I never quite understood what document refer to in this case.
>>> I do have a memory passing data between frames, but never done it between a js
>>> and html file.
>>
>> Why don't you buy a good book on html, another good book on javascript,
>> and READ THEM.

Why buy? everything is one web-search-engine search away.

> Better yet, buy a book on PHP and don't bother visitors with running
> javascript for basic functionality

Why not?

> Javascript is turned off in my default browser.
>
> I might fire up a different browser for *your* site, but I will
> probably look first for a site that has a better design. If I find
> one, I will go there instead.

People employing this criteria are the vast minority so you hardly exert
any sort of pressure to web developers.

Michael Haufe (\"TNO\")

5/18/2016 2:27:00 AM

0

On Tuesday, May 17, 2016 at 7:30:24 PM UTC-5, Aleksandro wrote:
> On 17/05/16 08:36, Wally W. wrote:
> > On Tue, 17 May 2016 10:17:52 +0100, Tim Streater wrote:

> >> Why don't you buy a good book on html, another good book on javascript,
> >> and READ THEM.
>
> Why buy? everything is one web-search-engine search away.

When coming from a position of ignorance, having a paradox of choice is hardly useful. What's disappointing is that the CLJS FAQ is quite dated regarding books/references:

<http://pointedears.de/scripts/faq/cljs/...

Admittedly I haven't done my part in submitting an update though...

I will of course give my personal suggestions of reading material on JavaScript for beginners/intermediate:

<http://eloquentjavascrip...
<http://effectivej...
<https://developer.mozilla.org/en-US/docs/Web/Java...
<http://speakingj...
<http://exploringj...

Tim Streater

5/18/2016 7:57:00 AM

0

In article <nhgcs1$7b8$1@dont-email.me>, Aleksandro
<aleksandro@gmx.com> wrote:

>People employing this criteria are the vast minority so you hardly exert
>any sort of pressure to web developers.

criterion, not criteria.

--
"A committee is a cul-de-sac down which ideas are lured and then
quietly strangled." - Sir Barnett Cocks (1907-1989)

Tim Streater

5/18/2016 7:59:00 AM

0

In article <nhgcs1$7b8$1@dont-email.me>, Aleksandro
<aleksandro@gmx.com> wrote:

>On 17/05/16 08:36, Wally W. wrote:
>> On Tue, 17 May 2016 10:17:52 +0100, Tim Streater wrote:
>>
>>> In article <ec9a7a6b-b3af-4d83-9b28-e9fff5c24f4b@googlegroups.com>,
>>> <jonas.thornvall@gmail.com> wrote:
>>>
>>>> I decided to try write abit more modular code, but i have no real good
>>>> example
>>>> of how to do it.
>>>>
>>>> Lets say i have index.html and main.js, i do have figured out how to call
>>>> main.js from index.html.
>>>>
>>>> But what i would like to know is how do i refer a form with a textfiel
>>>> within
>>>> index.html?
>>>> Do the script know in which document the refered form reside?
>>>>
>>>> In HTML pages with inline/embedded javascript, i know one do it like this.
>>>>
>>>> document.myform.mytext.value = somedata;
>>>>
>>>> I never quite understood what document refer to in this case.
>>>> I do have a memory passing data between frames, but never done it between
>>>> a js
>>>> and html file.
>>>
>>> Why don't you buy a good book on html, another good book on javascript,
>>> and READ THEM.
>
>Why buy? everything is one web-search-engine search away.

A book is a good reference. It may not be 100% up to date, but with the
sort of questions being asked that hardly matters. And it will likely
have a good *introduction* which will answer all these naive questions.

--
"The idea that Bill Gates has appeared like a knight in shining armour to
lead all customers out of a mire of technological chaos neatly ignores
the fact that it was he who, by peddling second-rate technology, led them
into it in the first place." - Douglas Adams

Fernando D. Bozzo

5/19/2016 9:22:00 AM

0

El miércoles, 18 de mayo de 2016, 4:26:51 (UTC+2), Michael Haufe (TNO) escribió:
> On Tuesday, May 17, 2016 at 7:30:24 PM UTC-5, Aleksandro wrote:
> > On 17/05/16 08:36, Wally W. wrote:
> > > On Tue, 17 May 2016 10:17:52 +0100, Tim Streater wrote:
>
> > >> Why don't you buy a good book on html, another good book on javascript,
> > >> and READ THEM.
> >
> > Why buy? everything is one web-search-engine search away.
>
> When coming from a position of ignorance, having a paradox of choice is hardly useful. What's disappointing is that the CLJS FAQ is quite dated regarding books/references:
>
> <http://pointedears.de/scripts/faq/cljs/...
>
> Admittedly I haven't done my part in submitting an update though...
>
> I will of course give my personal suggestions of reading material on JavaScript for beginners/intermediate:
>
> <http://eloquentjavascrip...
> <http://effectivej...
> <https://developer.mozilla.org/en-US/docs/Web/Java...
> <http://speakingj...
> <http://exploringj...

Hi Michael:

Are you the forum admin? If yes, then this links should be at the header of the forum as a fixed reference, as other Google groups have, because being as a normal post nobody can find them easyly.

Best Regards.-

Michael Haufe (\"TNO\")

5/19/2016 12:04:00 PM

0

On Thursday, May 19, 2016 at 4:21:43 AM UTC-5, Fernando D. Bozzo wrote:

> Hi Michael:
>
> Are you the forum admin?

No