Jump to content
  • 0

Passing parameters in if/else function


xfa180

Question

This is an example of a bit of code I have embedded into an HTML block in a Tabular Report Datapage:

<script>
function newFunction() {
if("[@field:FIELDNAME]" == "FIELDVALUE"){
window.open('http://www.site.com/page.html?parameter1=[@field:fieldname1]&parameter2=[@field:fieldname2]');
}
else {
alert ('no field value');
}
}
</script>

<input type="button" value="click me" onclick="newFunction()" />
When I view the source code of this script, after deploying the datapage, the parameter value appears in the 'if' statement, but the parameters are not appearing in the window.open() string. Even if I just call a parameter without the window.open() function, still no value. Anyone have any idea why this would be happening?

Thanks,

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

hi,

can you place alert statement after the 'if statement' too. e.g:

if("[@field:FIELDNAME]" == "FIELDVALUE"){

alert('fieldname1='+"[@field:fieldname1]");

alert('fieldname2='+"[@field:fieldname2]");

window.open('http://www.site.com/page.html?parameter1=[@field:fieldname1]&parameter2=[@field:fieldname2]');

}

Please check that you receive the correct value that you want to pass from querry string. I guess you will always receive the value from last record in your report. Therefore, instead of button creating a link might be better idea.

For example:

custom link

Hope it helps :)

Link to comment
Share on other sites

  • 0

On another note, it depends where you are using this script? If it is in a details page or update form [@field:fieldname] will read the value of the located record from the table. If the script is inside a submission form and you want to pass the values of input text fields then you should use:

[@InsertRecordfieldname]

Best,

Bahar M.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...