| |

VerySource

 Forgot password?
 Register
Search
View: 933|Reply: 4

js little problem, help me

[Copy link]

1

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-3-14 14:30:02
| Show all posts |Read mode
alert shows temparray [0], it should show //2016122909584262.jpg, how to execute eval's code,

var index = document.getElementById ("itemno"). selectedIndex;

var temparray = new Array ();
temparray.push ("// 2016122909584262.jpg");
temparray.push ("// 20161214113441953.jpg");
temparray.push ("");
eval ("alert ('temparray [" + index + "]')");
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-12 00:30:01
| Show all posts
You are just alert, what about eval.
Reply

Use magic Report

1

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-6-12 22:45:01
| Show all posts
Because index is a variable
Reply

Use magic Report

0

Threads

13

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-17 11:00:01
| Show all posts
Change eval("alert('temparray["+index+"]')"); to eval("alert(temparray["+index+"])");
Enough.
Reply

Use magic Report

1

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-6-17 19:45:01
| Show all posts
Thanks, the problem has been solved,
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list