Today, we have encountered an interesting problem, that is, adding support for images in the SharePoint survey. As we all know, the SharePoint survey supports the following types of fields. Of course, we can develop and implement it. However, this is not what we will introduce today. Today we will introduce no code development for JS implementation.
Next, let's take a look at what we want to achieve, such as (the page for participation in the survey is actually a page I have already prepared ):
For example, it is difficult to implement the IMG tag in the field that comes with SharePoint with the image option. Therefore, I want to write the IMG tag on the page and then find that it is output to the page as text, I thought of replacing the IMG tag with a JS script. So I modified the option content in the survey, as shown in (the option in the survey ):
Option text:
# Img_start width = "100" Height = "120" src = "http: // 10.5.92.11/bmdh/jyglb/doclib/yamukawa .jpg" # img_end zhangsan # Img_start width = "100" Height = "120" src = "http: // 10.5.92.11/bmdh/jyglb/doclib/yamukawa .jpg" # img_end Li Si # Img_start width = "100" Height = "120" src = "http: // 10.5.92.11/bmdh/jyglb/doclib/yamukawa .jpg" # img_end Wang Wu |
As shown in the above text, I replaced the front and back of the IMG label with # img_start and # img_end, which is also convenient for us to replace with the JS script. After the JS script is attached, if you are interested, refer:
<SCRIPT type = "text/JavaScript"> VaR divobj = Document. getelementsbytagname ("label "); For (VAR I = 0; I <divobj. length; I ++) { If (divobj [I]. innerhtml. indexof ("# img_start")> = 0) { VaR STR = divobj [I]. innerhtml; STR = Str. Replace ("# img_start", " STR = Str. Replace ("# img_end", "> </img> "); Divobj [I]. innerhtml = STR; } } </SCRIPT> |
Add a Web Part of the Content editor on the page, put the script in, and click OK to find the desired effect. Then, we also use JS scripts to implement the survey statistics page (for example). Here I will not talk nonsense. Let's look at the results directly.
Note: This is a simple idea. I would like to share it with you. As there are more and more developers in Sharepoint, my philosophy is: Unless necessary, I absolutely do not understand the code. Of course, there are also code implementations for this issue. I have attached the link. You can compare the two implementation methods. Haha, it's very late. Go to bed. Good night everyone.
Custom field implementation: http://blog.csdn.net/cxx2325938/article/details/8284741