<td><input type="radio" value='<%=str%>'  name="UserID"></td>

解决方案 »

  1.   

    <td><input type="radio" value='abcd"mmn'  name="UserID"></td>
    <td><input type="radio" value="abcd'mmn"  name="UserID"></td>
      

  2.   

    Yes 
    注意javascript 中的字符串的引用! 单引号和双引号
      

  3.   

    后台字符串输出到前台要经过转码
    如果是jsp
    请用以下的工具进行转码:
    输出到html里,用htmlEncoder
    输出到js里,用jsEncoder
    /*
     * Created by Seamus
     * Updated on 2004-10-21 by JK
     *
     */
    package com.jk.util;public class  CommStr
    {
      /**
      *replace the old string to new string in the given destination string.
      */
      public static java.lang.String strReplace(java.lang.String destStr, java.lang.String oldStr, java.lang.String newStr)
      {
        if(destStr==null)
          return "";
        String tmpStr = destStr;
        int foundPos = tmpStr.indexOf(oldStr);
        while (foundPos>=0)
        {
          tmpStr = tmpStr.substring(0,foundPos) + newStr + tmpStr.substring(foundPos + oldStr.length(),tmpStr.length());
          foundPos = tmpStr.indexOf(oldStr,foundPos+newStr.length());
        }
        return tmpStr;
      }  /**
      *Encode for HTML.
      */
      public static String htmlEncoder(String str)
      {
        if(str==null || str.equals(""))
          return "";
        String res_str;
        res_str=strReplace(str,"&","&amp;");
        res_str=strReplace(str," ","&nbsp;");
        res_str=strReplace(str,"<","&lt;");
        res_str=strReplace(str,">","&rt;");
        res_str=strReplace(str,"\"","&quot;");
        res_str=strReplace(str,"'","&#039;");
        return res_str;
      }  /**
      *Encode for HTML-Text.
      */
      public static String htmlTextEncoder(String str)
      {
        if(str==null || str.equals(""))
          return "";
        String res_str;
        res_str=strReplace(str,"&","&amp;");
        res_str=strReplace(str,"<","&lt;");
        res_str=strReplace(str,">","&rt;");
        res_str=strReplace(str,"\"","&quot;");
        res_str=strReplace(str,"'","&#039;");
        res_str=strReplace(str," ","&nbsp;");
        res_str=strReplace(str,"\r\n","<br>");
        res_str=strReplace(str,"\r","<br>");
        res_str=strReplace(str,"\n","<br>");
        return res_str;
      }  /**
      *Encode for URL.
      */
      public static String urlEncoder(String str) {
        return java.net.URLEncoder.encode(str) ;
      }  /**
      *Encode for XML.
      */
      public static String xmlEncoder(String str)
      {
        if(str==null || str.equals(""))
          return "";
        String res_str;
        res_str=strReplace(str,"&","&amp;");
        res_str=strReplace(res_str,"<","&lt;");
        res_str=strReplace(res_str,">","&gt;");
        res_str=strReplace(res_str,"\"", "&quot;");
        res_str=strReplace(res_str,"\'", "&acute;");
        return res_str;
      }  /**
      *Encode for SQL.
      */
      public static String sqlEncoder(String str)
      {
        if(str==null || str.equals(""))
          return "";
        String res_str;
        res_str=strReplace(str,"'","''");
        return res_str;
      }  /**
      *Encode for Javascript.
      */
      public static String jsEncoder(String str)
      {
        if(str==null || str.equals(""))
          return "";
        String res_str;
        res_str=strReplace(str,"'","\\'");
        res_str=strReplace(str,"\"","\\\"");
        res_str=strReplace(str,"\r\n","\\\n");
        res_str=strReplace(str,"\n","\\\n");
        res_str=strReplace(str,"\r","\\\n");
        return res_str;
      }}
      

  4.   

    xjdawu(无法界定) ,如果字符串中既有单引号,又有双引号,如何处理??
      

  5.   

    在vbs过滤:Replace(str,"&","&amp")
    Replace(str,"<","&lt")
    Replace(str,">","&rt")
    Replace(str,"\"","&quot")
    Replace(str,"'","&#039")
    Replace(str," ","&nbsp")
    Replace(str,"\r\n","<br>")
    Replace(str,"\r","<br>")
    Replace(str,"\n","<br>")