简体   繁体   中英

VBScript Erroring on getelementbyid for an element that doesn't exist

I have this block of code and when i = 9 it errors. The object T_009 does not exist in the html form, but I don't understand why it would cause it to error out, isn't that what the not is nothing checks for? I have several forms that use vbscript and don't have the time to convert them all so I'm stuck with what it is...

dim i, obj_src, obj_dest
for i = 2 to 720
    set obj_src = document.getelementbyid("T_" & lpad(i,"0",3))
    set obj_dest = document.getelementbyid("s" & lpad(i,"0",3))
    if not obj_src is nothing and not obj_dest is nothing then
        obj_dest.innerhtml = obj_src.value
    end if
    set obj_src = nothing
    set obj_dest = nothing
Next

我需要启用兼容模式

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM