| |

VerySource

 Forgot password?
 Register
Search
View: 819|Reply: 5

A simple js call problem. . . .

[Copy link]

1

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-11-26 21:30:01
| Show all posts |Read mode
There is a dropdownlist,
The javascript is as follows:
  function style()
    {
        var ddl=document.getElementById("DropDownList1");
        if(ddl.options[ddl.selectedIndex].value=="style 1")
        {
            document.getElementById("Label2").innerHTML="<link href=\"stylecss/stylecss.css\" rel=\"stylesheet\" type=\"text/css\" />";
        }
        else
        {
            document.getElementById("Label2").innerHTML="<link href=\"stylecss/stylecss1.css\" rel=\"stylesheet\" type=\"text/css\" />";
        }
    }

My current cs code page pageload has been added: this.DropDownList1.Attributes.Add("onchange", "javascript:style()");
Why is there an error when selecting items? ?
How to write? ? Tell me, brothers. .
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-11-27 02:00:01
| Show all posts
What went wrong?
Reply

Use magic Report

1

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-11-27 09:00:01
| Show all posts
When I select an item, the error "The object does not support this operation" appears.
Reply

Use magic Report

1

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-11-27 09:15:01
| Show all posts
It is the error message of the script. . . .
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-11-27 16:00:01
| Show all posts
document.getElementById("Label2")
When sending back, the server-side control changed its ID, and there is no way to get the control with getElementById.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-11-27 16:30:01
| Show all posts
Take a look at the source file, label2, what is the ID after returning from DropDownList
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