Discussions

Expand all | Collapse all

Get a field value for html page?

  • 1.  Get a field value for html page?

    Posted 05-21-2018 20:13
    I'm trying to set the value of an input on a popup html page onload using the value in a form field. But all i'm getting is this: "[object Object]"
     


    code:

    <script>
    var timg = window.opener.$("#_fid_43");
     $("#imgurl").val(timg);
    </script> 



    I've tried a few different things, but end with that same result.
    fid_43 is a Formula- Rich Text field that gives the image url for a record.

    Any ideas how to get that URL into that input?


  • 2.  RE: Get a field value for html page?

    Posted 05-21-2018 20:18
    Howdy Chad,

    Is this [object Object] field only used on a single record?  Or does it need to be dynamic based on a specific record?

    As of now, QB has no way of knowing what table or record it should look on for fid 43.  Permalinking is out of the question?


  • 3.  RE: Get a field value for html page?

    Posted 05-21-2018 20:24
    [object Object] is not a field it is the value I'm getting for the input (on error).

    The script is running on the html page. 

    Is what you're saying that I can't use jQuery to look at the window opener?


  • 4.  RE: Get a field value for html page?

    Posted 05-21-2018 20:29
    Gotchya.  Take a look at my reply below-  I think it may help.  You can accomplish this with jQuery, but on a stand-alone code page, the jQuery will have no idea what #_fid_43 means, you have to provide it with an actual link, perhaps utilizing the API. 


  • 5.  RE: Get a field value for html page?

    Posted 05-21-2018 20:35
    I've played around with a couple of api methods. My problem with the api is how does my html page get the rid for the query? 


  • 6.  RE: Get a field value for html page?

    Posted 05-21-2018 20:40
    Ok, that's a solvable issue.  Is the button that triggers the pop-up a usermade button? Or is it native quickbase?

    It will have to be a userbased button, so you can pass a variable over to the pop-up, which then jQuery can utilize.  

    For example, in the pop-up button you can end the url with &rid=[Record ID#]

    And then you can have Javascript like so
    var rid = urlParam('rid');
    Simple!

    (Let me know if you're able to get this one working)


  • 7.  RE: Get a field value for html page?

    Posted 05-21-2018 21:02
    Params!!!

    No api needed. just loaded my formula field in there.

    <script>
    var url_string = window.location.href;
    var url = new URL(url_string);
    var img = url.searchParams.get("img");
    console.log(img);
    $("#imgurl").val(img);
    </script>

    Thanks!


  • 8.  RE: Get a field value for html page?

    Posted 05-21-2018 22:07
    Woo!  Glad I was able to help you out, even if I didn't directly solve your issue.  :^)


  • 9.  RE: Get a field value for html page?

    Posted 05-21-2018 20:26
    Replying to myself here:

    You can utilize API_GetRecordInfo for this, should you have all the prerequisites.. (RecordID & DBID)

    https://<DOMAIN>.quickbase.com/db/<DBID>?a=API_GetRecordInfo&rid=<RID>&apptoken=<APPTOKEN>

    You'll then have to parse out the response for the specific _fid_ you're looking for, and you can return those results.

    Let me know if this helps at all.