怎样获得htmltextbox的文本值

html-css07

怎样获得htmltextbox的文本值,第1张

假设文本框的ID和Name均为myBox,则可用下面的方法获取

1、var text=document.getElementsByName("myBox").value//js获取,通过name

2、var text=document.getElementsById("myBox").value//js获取,通过id

3、var text=$("#myBox").val()//jquery获取

在目前用法,jquery获取用法最多,也最简便

1)利用配置字符串 ,如 ConfigString=”Cut,Copy” , 则只显示剪切,复制按钮

所有可采用的配置有:Cut,Copy,Paste,Delete,Undo,Redo,Print,Bold,Italic,Underline,Strikethrough,Superscript,Subscript,InsertImage,CreateLink,Unlink,FontForeColorPicker,FontBackColorPicker,RemoveFormat,FormatBlock,FontName,FontSize|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull,insertunorderedlist,insertorderedlist,Indent,Outdent,inserthorizontalrule,InsertDate,InsertTime,WordCount,WordClean,UploadPanel,SourceViewer

其中“|”表示换到下一个工具栏显示

2)利用子控件,即将HtmlTextBox已实现的子控件加入到HtmlTextBox标签内部,或外部:

子控件示例:

<!--[if !supportLineBreakNewLine]-->

<!--[endif]-->

<htb:htmltextbox id="HtmlTextBox2" runat="server" StyleConfig="CoolBlue" ConfigString="Blod,RichTextBox" ConfigMode="None" Height="160px" Width="288px">

<htb:ToolBar Runat="server" id=" ToolBar 1">

<htb:sourceviewer id="Sourceviewer1" runat="server"></htb:sourceviewer>

</htb:ToolBar>

<htb:RichTextBox id="Sourceviewer4" runat="server"></htb:RichTextBox>

</htb:htmltextbox>

<htb:UploadPanel id="Uploadpanel2" runat="server" ConfigMode="Lovely" TopContainerID="HtmlTextBox2"Width="920px"></htb:UploadPanel>

<!--[if !supportLineBreakNewLine]-->

<!--[endif]-->

如上:sourceviewer , RichTextBox加入HtmlTextBox内部, UploadPanel置于HtmlTextBox标签外部,通过TopContainerID与HtmlTextBox关联

这里要注意的一点是:利用第一种方法时:要将configmode设置为configstring,否则还是启用的默认的方式

如何启用图片和附件上传功能:

调用方法1:ConfigMode="EnableAll"时上传控件会出现,设置一下上传文件夹路径即可。

路径相对站点根目录。

调用方法2:利用外置控件

<htb:htmltextbox id="Htmltextbox4" runat="server" ConfigMode="Default" Width="920px"></htb:htmltextbox>

<htb:UploadPanel id="UploadPanel1" runat="server" ConfigMode="Lovely" TopContainerID="Htmltextbox4"

将UploadPanel1 的 TopContainerID与Htmltextbox4关联,则上传的图片自动插入Htmltextbox4中

具体功能及属性查看控件文档