Announcement

Collapse
No announcement yet.

Form field as link?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form field as link?

    In a form (Editable Grid View) a field should be displayed as link and editable as text. How does it work? sc_link is not working (in a form).

    If that is not possible, how can I add a normal link? (<a href="http://...>My Link</a>)
    Best regards: - Reinhard -

    I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

  • #2
    Hi,

    i hope this might point you in the right direction.

    In the onLoadRecord event something like this:
    if(!empty({field}))
    {
    {field} = "<a href= http://www.".{field}.">".{field}."</a>";
    }

    In addition to it you could use an onFocus Ajax event to clear the field when the user clicks into it.

    jsb

    Comment


    • #3
      Originally posted by jsbinca View Post
      i hope this might point you in the right direction.
      Thanks, but unfortunately not ...

      If i use a normal grid (= view only), i can use sc_link (<myfield>, "http://www.domain.com/invoice/2013/2013-10999.pdf", , "2013-10999", "_blank") in event onRecord. When i click on that link, the linked .pdf opens.

      How can I have a similar behavior in a form and edit the field as a normal text (only this part: "2013-10999")? With your solution the field contains the full link, but this is not desired.
      Best regards: - Reinhard -

      I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

      Comment


      • #4
        Originally posted by RHS View Post
        ... With your solution the field contains the full link, but this is not desired.
        You are right, and you only could fiddle around with an onClick Ajax event to clear the field and show the right value. But that would probably be too much confusion for the end user. It would be much easier if we could catch the status change of the line. (just a dream)

        On a second thought, what about mimic the behavior of a URL field? It is not exactly what you want but may come close.

        1. Mark your field as a hidden field.
        2. Create a custom text field in your form. Mark 'Use lookup to display the field description.'
        Create a SQL command:
        SELECT IF(doc_name > '',CONCAT("<a href= http://www.wherever/it/may/be/",doc_name,">",doc_name,"</a>"),'')
        FROM document
        WHERE doc_id = {doc_id}

        3. In the onValidate event copy the value to your hidden field and clear your input field.

        The downside is you get an empty input field when you change to edit mode. But you can spice it up with a watermark and Ajax.
        Not necessarily elegant but could do the job.


        jsb

        Edit:
        Oh my! Sometimes it makes sense to switch on the brain.
        How about an printer icon? Then you can forget all that additional stuff.
        Just use the lookup feature with a SQL command like:

        SELECT IF(doc_name > '',CONCAT("<a href= 'http://www.wherever/it/may/be/",doc_name,".pdf' target ='_blank'<img_src='path/to/your/image'/></a>"),'')
        FROM document
        WHERE doc_id = {doc_id}
        Last edited by jsbinca; 12-06-2013, 04:35 PM.

        Comment

        Working...
        X