Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Coding problem

Reply
Thread Tools

Coding problem

 
 
Robert Baer
Guest
Posts: n/a
 
      08-22-2013
The following code "works" in a strange way; see the comments for
details.
1) why is that document.write necessary for operation?
2) why doesn't the altered variable "title" remain changed?
3) i would like to change displayed page, based on map visits

Help? Comments?


<SCRIPT type="text/javascript">
// <img id="page" src=title alt="Codatron page 1">
// src="images/CodatronP1.png"
var title="images/CodatronP1.png";
var dir=-1;
var num=3;
function incrPage(dir,title)
{
num=title.substr(16,1).valueOf();
if (dir===-1)
{
num=num-1;
if (num===0) {num=7;}
}
else
{
num=num+1;
if (num=== {num=1;}
}
title=title.substr(0,16)+num+title.substr(17);
document.write("###"+title+"*");
// above correct at page 7 being "previous" to page 1 (sequence 1,2,,7,1
etc)
// *NOTE* the document.write MUST exist for the map visits to work ???
}
incrPage(dir,title);
// document.write("***"+title+"* *#");
// above is wrong, with title equal to unchanged initial def

// document.getElementById("page").innerHTML=title;
</script>

<div>
<img src="ShuttleN.png" alt="Select" usemap="#PageSelect"
</div>
<div>
<!-- visiting mapped areas give "###-1*" or "###1*" in new screen -->
<map id="images/CodatronP5.png" name="PageSelect">
<area shape="rect" alt="Minus" coords="65,0,135,35"
src="N.PNG" onMouseover="incrPage(-1,id)" >
<area shape="rect" alt="Plus" coords="590,0,668,35"
src="P.PNG" onMouseover="incrPage(1,id)" >
<area shape="default" nohref="nohref" alt="" >
</map>
</div>

<!-- display page one; would like to change that based on map visits -->
<div class=" container_24">
<div class="wrapper">
<img id="page" src="images/CodatronP1.png" alt="Page">
</div>
</div>

 
Reply With Quote
 
 
 
 
Doug Miller
Guest
Posts: n/a
 
      08-22-2013
Robert Baer <(E-Mail Removed)> wrote in newsptRt.321878$(E-Mail Removed):

> The following code "works" in a strange way; see the comments for
> details.
> 1) why is that document.write necessary for operation?
> 2) why doesn't the altered variable "title" remain changed?
> 3) i would like to change displayed page, based on map visits
>
> Help? Comments?


You'll probably have better luck posting in one of the javascript groups.
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      08-22-2013
Robert Baer <(E-Mail Removed)> writes:

> Doug Miller wrote:
>> Robert Baer<(E-Mail Removed)> wrote in newsptRt.321878$(E-Mail Removed):
>>
>>> The following code "works" in a strange way; see the comments for
>>> details.
>>> 1) why is that document.write necessary for operation?
>>> 2) why doesn't the altered variable "title" remain changed?
>>> 3) i would like to change displayed page, based on map visits
>>>
>>> Help? Comments?

>>
>> You'll probably have better luck posting in one of the javascript groups.

> I have found only one JS group, and it is essentially dead.
> Hopefully, http://www.codingforums.com can help.
> Thanks.


comp.lang.javascript is a possibility.

And your questions:

1) It's not, but it's one reasonable way to inject some text into an
existing document.

2) This is a basic property functions and arguments. Argument passing
is by copying:

vat title = "abc";

function test1(t) { t = "def"; }
function test2(title) { title = "def"; }

test1(title);
test2(title);
// Both functions are essentially the same and neither call changes
// the value of the "outer" variable called title.

If you need a changed value, get the function to return it.

title = calculateNewTitle(title);

3) Pass

--
Ben.
 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-22-2013
Doug Miller wrote:
> Robert Baer<(E-Mail Removed)> wrote in newsptRt.321878$(E-Mail Removed):
>
>> The following code "works" in a strange way; see the comments for
>> details.
>> 1) why is that document.write necessary for operation?
>> 2) why doesn't the altered variable "title" remain changed?
>> 3) i would like to change displayed page, based on map visits
>>
>> Help? Comments?

>
> You'll probably have better luck posting in one of the javascript groups.

I have found only one JS group, and it is essentially dead.
Hopefully, http://www.codingforums.com can help.
Thanks.

 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-25-2013
Doug Miller wrote:
> javascript groups.

There are no functional javascript groups.

 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-25-2013
Ben Bacarisse wrote:
> Robert Baer<(E-Mail Removed)> writes:
>
>> Doug Miller wrote:
>>> Robert Baer<(E-Mail Removed)> wrote in newsptRt.321878$(E-Mail Removed):
>>>
>>>> The following code "works" in a strange way; see the comments for
>>>> details.
>>>> 1) why is that document.write necessary for operation?
>>>> 2) why doesn't the altered variable "title" remain changed?
>>>> 3) i would like to change displayed page, based on map visits
>>>>
>>>> Help? Comments?
>>>
>>> You'll probably have better luck posting in one of the javascript groups.

>> I have found only one JS group, and it is essentially dead.
>> Hopefully, http://www.codingforums.com can help.
>> Thanks.

>
> comp.lang.javascript is a possibility.

* Not functional, been empty for ages.

>
> And your questions:
>
> 1) It's not, but it's one reasonable way to inject some text into an
> existing document.

* Function does not work without that line of code. I agree, it should.
The "return" statement oes nothing except guarantee that JS proceeds
no further (and that agrees with the documentation as far as execution
is concerned).

>
> 2) This is a basic property functions and arguments. Argument passing
> is by copying:
>
> vat title = "abc";
>
> function test1(t) { t = "def"; }
> function test2(title) { title = "def"; }
>
> test1(title);
> test2(title);
> // Both functions are essentially the same and neither call changes
> // the value of the "outer" variable called title.
>
> If you need a changed value, get the function to return it.
>
> title = calculateNewTitle(title);

* Oh! Thanks; the online "tutorial" does not give refinements like that.

>
> 3) Pass
>

2 out of 3 is excellent!
Thanks.

 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-25-2013
Robert Baer wrote:
> Doug Miller wrote:
>> Robert Baer<(E-Mail Removed)> wrote in
>> newsptRt.321878$(E-Mail Removed):
>>
>>> The following code "works" in a strange way; see the comments for
>>> details.
>>> 1) why is that document.write necessary for operation?
>>> 2) why doesn't the altered variable "title" remain changed?
>>> 3) i would like to change displayed page, based on map visits
>>>
>>> Help? Comments?

>>
>> You'll probably have better luck posting in one of the javascript groups.

> I have found only one JS group, and it is essentially dead.
> Hopefully, http://www.codingforums.com can help.
> Thanks.
>

Well, if i can only figure out how to POST after the preview...
Anyone have a clue?

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      08-25-2013
Robert Baer <(E-Mail Removed)> writes:

> Ben Bacarisse wrote:
>> Robert Baer<(E-Mail Removed)> writes:
>>
>>> Doug Miller wrote:
>>>> Robert Baer<(E-Mail Removed)> wrote in newsptRt.321878$(E-Mail Removed):
>>>>
>>>>> The following code "works" in a strange way; see the comments for
>>>>> details.
>>>>> 1) why is that document.write necessary for operation?
>>>>> 2) why doesn't the altered variable "title" remain changed?
>>>>> 3) i would like to change displayed page, based on map visits
>>>>>
>>>>> Help? Comments?
>>>>
>>>> You'll probably have better luck posting in one of the javascript groups.
>>> I have found only one JS group, and it is essentially dead.
>>> Hopefully, http://www.codingforums.com can help.
>>> Thanks.

>>
>> comp.lang.javascript is a possibility.

> * Not functional, been empty for ages.


I posted a reply there yesterday. I see messages there every day, more
or less, -- more that I see here, for example.

>> And your questions:
>>
>> 1) It's not, but it's one reasonable way to inject some text into an
>> existing document.

> * Function does not work without that line of code. I agree, it should.
> The "return" statement oes nothing except guarantee that JS proceeds
> no further (and that agrees with the documentation as far as execution
> is concerned).


Misunderstanding here. When I said that the document.write was not
necessary I meant that there are other ways to do the kind of thing that
document.write does. The specific question (which is what I think you
were asking) of why the code works with it, and does not work without
it, seems unanswerable without more data. The context of the code,
and the definition of "works" and "not works" being the main things I'd
want to know. I agree it looks odd, but that's all I can say.

<snip>
--
Ben.
 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-26-2013
Hot-Text wrote:
> "Robert Baer" <(E-Mail Removed)> wrote in message
> news:dltSt.150347$(E-Mail Removed)...
>> Robert Baer wrote:
>>> Doug Miller wrote:
>>>> Robert Baer<(E-Mail Removed)> wrote in
>>>> newsptRt.321878$(E-Mail Removed):
>>>>> The following code "works" in a strange way; see the comments for
>>>>> details.
>>>>> 1) why is that document.write necessary for operation?
>>>>> 2) why doesn't the altered variable "title" remain changed?
>>>>> 3) i would like to change displayed page, based on map visits
>>>>> Help? Comments?
>>>> You'll probably have better luck posting in one of the javascript
>>>> groups.
>>> I have found only one JS group, and it is essentially dead.
>>> Hopefully, http://www.codingforums.com can help.
>>> Thanks.

>> Well, if i can only figure out how to POST after the preview...
>> Anyone have a clue?
>>

>
> Same more info for
> < http://www.freewebmasterhelp.com/tutorials/javascript >

Wow! Nicely done, good presentation, nice examples.
Tanks a lot!!

 
Reply With Quote
 
Robert Baer
Guest
Posts: n/a
 
      08-27-2013
Hot-Text wrote:
> "Robert Baer" <(E-Mail Removed)> wrote in message
> news:aOMSt.184242$(E-Mail Removed)...
>> Hot-Text wrote:
>>> "Robert Baer" <(E-Mail Removed)> wrote in message
>>> news:dltSt.150347$(E-Mail Removed)...
>>>> Robert Baer wrote:
>>>>> Doug Miller wrote:
>>>>>> Robert Baer<(E-Mail Removed)> wrote in
>>>>>> newsptRt.321878$(E-Mail Removed):
>>>>>>> The following code "works" in a strange way; see the comments for
>>>>>>> details.
>>>>>>> 1) why is that document.write necessary for operation?
>>>>>>> 2) why doesn't the altered variable "title" remain changed?
>>>>>>> 3) i would like to change displayed page, based on map visits
>>>>>>> Help? Comments?
>>>>>> You'll probably have better luck posting in one of the javascript
>>>>>> groups.
>>>>> I have found only one JS group, and it is essentially dead.
>>>>> Hopefully, http://www.codingforums.com can help.
>>>>> Thanks.
>>>> Well, if i can only figure out how to POST after the preview...
>>>> Anyone have a clue?
>>> Same more info for
>>> < http://www.freewebmasterhelp.com/tutorials/javascript >

>> Wow! Nicely done, good presentation, nice examples.
>> Tanks a lot!!
>>

>
> You're welcome
>
> I was doing a Internet Archive: Wayback Machine
> Looking for old Editor Software back in 1998
> and one of the websites had a like to freewebmasterhelp
> and I saw the JavaScript and remember you
>
>

With that reference, and a few hours of fiddling, i am _close_ to
getting what i want.
Thanx for the help!

Have seven images and want to cycle thru them + for 7,1,2,3,,6,7 and
- for 1,7,6,5,,2,1.
Using HTML usemap and specific image names, + increments its given
name in that part of code, and - decrements its given name in that part
of code; both work nicely.
Used two JS functions; crudely first called via mouseOver(), one
presents a given name and calls second that properly cycles thru the
numbers/names.
But it "steps" only once.
I think that if there was such a beastie as a HTML variable, i could
solve this in short order.

Got the code and query posted in codingforums.com .


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
coding problem or player problem? richard HTML 13 04-24-2012 06:56 PM
Coding problem (beginner question) smu VHDL 3 06-28-2006 05:13 AM
general coding issues - coding style... calmar Python 11 02-21-2006 10:36 AM
Problem with coding Bart Schelkens ASP .Net 1 07-29-2004 07:13 PM
simple jsp coding problem Jason Java 1 09-08-2003 07:49 AM



Advertisments