HTML Links in fileInput labels


#1

My app has the normal fileInput to read in a file, which is just

fileInput('file', 'Choose File',
	accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))

Many of the files my users read in have a very specific structure, and I'm trying to create an online help that is very easy to use. What I would like is (pseudo-code), something like this

fileInput('file', 'Choose File (click here)',
	accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))

Where the "click here" would be HTML that would open a pop up window. The code would actually be something like this:

<a href="#" onclick="window.open('layout.jpg', 'newwindow', 'width=300, height=250'); return false;">click here</a>

In fact, if I put this into a file in my HTML directory called foo.html and then below the fileInput do something like:

includeHTML("HTML/foo.html")

Then, this works just as I would expect. But, it would be more convenient if this link were next to the "choose file" input box.

Any suggestions for accomplishing that?


#2

I don't have an answer, but I fixed the code formatting in your post so that it's actually possible to see your HTML/javascript (and to make the R code easier to read as well). In the future, you can do the same thing by selecting text in the posting box and clicking the </> button :grin:


#3

You can make your label a span, and use tags$a in it. For example:

      fileInput(
        'file1', 
        span("Choose File",
          tags$a(
            "(click here)",
            href = "#",
            onclick = "window.open('layout.jpg', 'newwindow', 'width=300, height=250'); return false;"
          )
        ),
        accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv')
      )

image