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

Array Issue 3nd Part.

P: n/a
Hi all,

In this URL.

http://www.streetball.cl/JS/ChangeOrder.php?id=1
If you view the source code, you'll see the original order (JavaScript
Array):

ID = ORDER

Original Order:

1 = 1
4 = 2
5 = 3
7 = 4
Try this, move the first image to the last one, when you clicks on
"SubmiT" this order should be:

1 = 4
4 = 2
5 = 3
7 = 1

But this show:

1 = 2
4 = 3
5 = 4
7 = 1

So, any know what is the problem ?,

Thanks in advanced.

-- eft0.
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,
It works for me....do you clear the cache on your browser every once in
a while.

The only line I am not sure about is the:
eval("document.frm1.id_" + Thumbnails[cnt][3] + ".value='" + Order2
+"';");

It seems like you are only updating one form element value per loop
when it seems to me you should change two ---the one you are moving the
the one that moves into it's place.

But then again it seems to work for me other than the fact that the
order shows
5=>
4=>
1=>
7=>
on the server requests.
??

Jul 23 '05 #2

P: n/a
eft0 wrote:
Hi all,

In this URL.

http://www.streetball.cl/JS/ChangeOrder.php?id=1
If you view the source code, you'll see the original order (JavaScript Array):

ID = ORDER

Original Order:

1 = 1
4 = 2
5 = 3
7 = 4
Try this, move the first image to the last one, when you clicks on
"SubmiT" this order should be:

1 = 4
4 = 2
5 = 3
7 = 1

But this show:

1 = 2
4 = 3
5 = 4
7 = 1

So, any know what is the problem ?,

Thanks in advanced.

-- eft0.


Just as a side issue - lines of JavaScript like this:

eval("alert('MOVE2: ' + document.frm1.id_" + Thumbnails[new_cnt][3] +
".value);");

....are patently ridiculous. Instead of simply writing a line of actual
code & running it, you're expressing it (painfully) as a string, then
running it through eval() to 'de-string' it so it will actually run.
It's as if you were scripting twice for every statement, once in
'string-o-javascript' and then in 'genuine-jav-o-script'.

alert('MOVE2: ' + document.frm1['id_' +
Thumbnails[new_cnt][3]].value);

And:

document['img_' + cnt].src = Thumbnails[new_cnt][1];

http://jibbering.com/faq/faq_notes/square_brackets.html

Jul 23 '05 #3

P: n/a
"...are patently ridiculous."
Ouch...sure it ain't pretty but it does do the job. Was tempted to
point it out myself. Not likely to be the cause of the trouble, though
;-)

Jul 23 '05 #4

P: n/a
eric wrote:
"...are patently ridiculous."
Ouch...sure it ain't pretty but it does do the job.
That depends on your definition of "does do the job". Its tantamount to
using a sledgehammer to drive a finishing nail in a board. Sure, it
"does the job" but its not the most efficient way to do it.
Was tempted to point it out myself.
Nothing wrong with pointing out mistakes in code, especially when that
code is being questioned.
Not likely to be the cause of the trouble, though


Me either, but would you mind reading the Group FAQ?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #5

P: n/a
Its Solved, thanks to all.
Jul 23 '05 #6

P: n/a
Randy Webb wrote:
eric wrote:
"...are patently ridiculous."
Ouch...sure it ain't pretty but it does do the job.

That depends on your definition of "does do the job". Its tantamount to
using a sledgehammer to drive a finishing nail in a board. Sure, it
"does the job" but its not the most efficient way to do it.


I disagree. If the objective was to consume far more energy
than required and provide an opportunity to demolish part or all
of the building at the same time as driving the nail (presuming
all goes well), then a sledgehammer makes perfect sense. >-)
--
Zif
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.