0

Is there a way to do this? <'param name = "ticket" value = "getTicket()">

getTicket() is my Javascript function. Whatever the function returns, that should be the value of the parameter tag.

I cant set it explicitly using Javascript "document.getElem...." because I want the value to be loaded at the time of page load. Or, while the parameter is being set.

For further info, I am trying to do this for Tableau Trusted Authentication.

Yaje
  • 2,479
  • 14
  • 31
user3709813
  • 121
  • 1
  • 7

4 Answers4

1

Are you using server-side scripting?

Isn't more effectively to do what you do using the request/response ways?

Like directly using <%=ticketValue%> (ASP way) or ${ticketValue} (JSP way)?

Stratus3D
  • 4,023
  • 2
  • 30
  • 58
Rafael dAS
  • 109
  • 4
0

You may use Document.Write as follows:

<'param name = "ticket" value = "<script>
document.write(getTicket());
</script>">
mrida
  • 1,101
  • 1
  • 10
  • 14
0

You can access node from JavaScript right after it was created. You're not obligated to wait for DOMContentLoaded event. So this code will work as expected:

<script>
  function getTicket() {
    return 'whatever';
  }
</script>

<param name="ticket" value="" class="js-ticket">
<script>
  var ticket = document.querySelector('.js-ticket');
  ticket.value = getTicket();

  console.log(ticket);
</script>

See demo.

This approach is better than using document.write, see good explanation.

Community
  • 1
  • 1
raidendev
  • 2,549
  • 1
  • 20
  • 23
0

You can use jquery $(document).ready() function callback. If jquery isn't available, then you can use the equivalence of it.

$(document).ready equivalent without jQuery

Then you can access document.getElement.

Community
  • 1
  • 1
Phuoc Do
  • 1,326
  • 10
  • 14