简体   繁体   中英

Line Breaks in Notepad++

How to get the following code the run properly in notepad++ with + ?

document.write("<table id='resultTable' border='1'><tr><th>Name:</th>"+"<td> <input type="text" name="FullName2" id="fname2" readonly></td></tr>"+"
         <th>Member ID:</th><td> <input type="text" name="MemberID2" id="mid2"></td> <tr> <th>Size:</th>
            <td> <input type="text" name="Size" id="size" value="" readonly> </td> </tr> <tr> <th>Color: </th> <td>
                <input type="text" name="ColorR" id="cr" readonly> </td> </tr> <th>Delivery Option: </th> <td>
            <input type="text" name="Deliver" id="dh2" readonly> </td></table>
    }

Notepad unlike other IDES has an issue of reading lines properly if they are not broken off in the right places. The code I wish to show is having such issue.

Your code itself is erroneous. When expressing a string in more than one line, you have to express it as adding string segments. Furthermore, there are errors in individual string literals - since you are intending to let double quotation marks be part of the string, you have to escape it.

When expressing a string literal in multiple lines, each line must be a string literal followed by a plus, and all "internal quotation marks" within the string must be escaped.

In your current code, other IDEs might also not work as intended.

Consider this edited code - this should work on Notepad++:

document.write("<table id='resultTable' border='1'><tr><th>Name:</th><td> <input type=\"text\" name=\"FullName2\" id=\"fname2\" readonly></td></tr>"+
        "<th>Member ID:</th><td> <input type=\"text\" name=\"MemberID2\" id=\"mid2\"></td> <tr> <th>Size:</th>" +
        "<td> <input type=\"text\" name=\"Size\" id=\"size\" value=\"\" readonly> </td> </tr> <tr> <th>Color: </th> <td>" +
        "<input type=\"text\" name=\"ColorR\" id=\"cr\" readonly> </td> </tr> <th>Delivery Option: </th> <td>" +
        "<input type=\"text\" name=\"Deliver\" id=\"dh2\" readonly> </td></table>")

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