LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-21-2010, 01:47 AM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
Javascript problem


Edit:

Solved. It was a totally different sort of a problem. (The code was good.)


Im am completely noob to Javascript, and cannot debug this code of mine:

Code:
function pgupf(){
  x=eval(document.getElementById('actpageno').value);
  y=x-1;
  z=x+1;
  if (document.layers) {
    document.layers["layer" + y].visibility='hide';
    document.layers["layer" + x].visibility='show';
  } else {
    document.all["layer" + y].style.visibility='hidden';
    document.all["layer" + x].style.visibility='visible';
  }
  document.getElementById('actpageno').value=z;
}
The code should "page up" between layers ("pages"), i.e.:
a) read out the "pageno" of the present layer (from form field "actpageno")
b) hide the present layer (its index equals to: the old value of actpageno - 1)
c) show the next layer (its index equals to the old value of pageno)
d) store the new value of "pageno" of the next layer in form field "actpageno"

(Layers are numbered from 0, whilst pagenos starts from 1, that is why the index of the present layer is actpageno - 1).

The code does all through a)-c), but d) is never done: the "actpageno" form field always shows "1" in firefox.
I am convinced that form field "actpageno" has the new value assigned (because the value of that field is retrieved by the code during hiding/showing the layers and that works as expected from page 1 to the last page 3), yet it is not shown in the field itself (using firefox as a browser). Why? Am I missing something?

Last edited by J_Szucs; 06-22-2010 at 03:36 AM.
 
Old 06-21-2010, 07:17 AM   #2
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
I think I found the culprit: I did not close the If construct with a semicolon. I will try.
 
Old 06-21-2010, 11:41 AM   #3
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
U nfortunately, this was not the reason. The value of the form input "actpageno" is still assigned by the function, but is not displayed in the browser window.

Why?

Edit:
Not only the same funtion that assigned the new value can read it from the .value property of that text input, but other functions assigned to the onClick event of other buttons can read the new value, too.
Only the value displayed in the text input is the old one. How to refresh that text input in order to display the new value that has been assigned to it?

Edit1:
If the function assigns the new value to a text input that is on an other form outside this div, then the assigned value is immediately shown in that field.
If the text input is on the same form (and within the same div), then the new value is assigned, but never shown. What the heck is this?

Does tha text input "work" so strangely because it is in a div layer, together with the buttons that manipulate its value?

Last edited by J_Szucs; 06-21-2010 at 02:30 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript mouseover problem frieza Programming 0 03-28-2009 08:36 PM
javascript problem with IE alitrix Programming 9 05-31-2006 10:14 PM
Java/Javascript problem????? Jadewolf Linux - Software 2 10-25-2003 07:06 PM
Javascript in Linux problem? BajaNick Linux - Software 5 10-20-2003 12:41 PM
Elinks: javascript problem ashesh Linux - General 1 07-21-2003 02:06 AM


All times are GMT -5. The time now is 09:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration