By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Optimize My Javascript

P: n/a
I create most of my javascripts by modifying others, therefore, I do
not have a vast knowledge of it and my question may seem trivial but
please help me.

If you go to my page http://www.dcs-chico.com/~denmarks/relative.html
you can see a simple script that uses the index returned from two pull
down menus to extract text from a table. I am looking for the best way
to display the result. I am currently using a text input form which
works but does not seem to be the best option. I would rather just have
the text appear directly on the page (without redrawing the page) and
not within a text box. Another problem is that even though the box is
read only, if someone places the curser in the box and presses return a
file not found message appears.

--
Dennis M. Marks
Do not reply with e-mail to yahoo. I do not monitor mailbox. It is for
collecting spam.
You can use the following address (rot 13) qr******@qpfv.arg
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Dennis M. Marks" <de******@yahoo.com> writes:
If you go to my page http://www.dcs-chico.com/~denmarks/relative.html ....
I am currently using a text input form which works but does not seem
to be the best option. I would rather just have the text appear
directly on the page (without redrawing the page) and not within a
text box.
I think it looks fine. It is also the most compatible way of adding
information to a page. Other methods are:
- Netscape 4 layers
- IE 4+ innerHTML
- W3C DOM node manipulation (IE 5+,Mozilla, Opera 7, etc.)
- Iframe and document.write to it (don't know exactly which browsers).
No browser supports all of these, and none of these methods are supported
by all browsers.
Using a text input element works in all of these browser and more. In
some browsers, it is the *only* way to add content after the page has
loaded.
So, if you really want to use another method, you must tell us which
browsers needs to be supported. Then we can tell you how to do it.
(There is something about it in the FAQ too:
<URL:http://jibbering.com/faq/#FAQ4_15>)

If it looks so bad, style it:
<style type="text/css">
#output {
background: #0ff;
border:0px solid #0ff;
font: inherit;
}
</style>
and give the output field id="output". That should make it look like normal
text in those browsers that allow it.
Another problem is that even though the box is read only,
if someone places the curser in the box and presses return a file
not found message appears.


Your form element is generally not necessary if you don't want to
submit the form anyway. However, Netscape 4 only allows form controls
inside a form element, and it makes addressing the controls much easier.

A typical sign that you don't use the form element for submitting is
that you don't know what to write in the "action" attribute. You have
written "post", which should really be in the "method" attribute. The
"action" attribute should contain an URL.

If you don't have access to server side scripting, so you could make
the application work even if the client have no Javascript available,
I would let the "action" URL point to a page that explains that the
page needs Javascript to work. Then I would add an onsubmit handler
that prevented the form from being submitted if Javascript is available.
I.e.,
<form id="form" name="form"
method="post" action="noJS.html" onsubmit="return false">

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
In article <d6**********@hotpop.com>, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:

<SNIP>
I think it looks fine. It is also the most compatible way of adding
information to a page. Other methods are:
- Netscape 4 layers
- IE 4+ innerHTML
- W3C DOM node manipulation (IE 5+,Mozilla, Opera 7, etc.)
- Iframe and document.write to it (don't know exactly which browsers).
No browser supports all of these, and none of these methods are supported
by all browsers.
Using a text input element works in all of these browser and more. In
some browsers, it is the *only* way to add content after the page has
loaded.
So, if you really want to use another method, you must tell us which
browsers needs to be supported. Then we can tell you how to do it.
(There is something about it in the FAQ too:
<URL:http://jibbering.com/faq/#FAQ4_15>)

<SNIP>

Thanks, that helped a lot.

--
Dennis M. Marks
Do not reply with e-mail to yahoo. I do not monitor mailbox. It is for
collecting spam.
You can use the following address (rot 13) qr******@qpfv.arg
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.