Jump to content

Combining Onclick With If/else Conditions


Recommended Posts

Our users place bids for contracts but we are having difficulty getting them through the registration process.  We'd like to try showing the users all of the available contracts to generate interest, but then restrict their ability to actually place the bid based on where they are in the registration process (i.e. if they have completed all of their forms).

 

We'd like to have the following occur:

 

When a user clicks on a "View Details" html link next to a contract, they are redirected based on their @Status from their authorization.  If they have not completed all of their forms, they will be directed to a page with instructors for form upload.  If they have completed the forms, they continue on to see the details of the contracts.

 

Please note that this doesn't occur on Login - we want the redirect to occur after clicking on a link within the datapage.

 

Thanks!

Casara

Link to comment
Share on other sites

You need to have the status field in Authentication table to know which user completed the process then have a code to write the URL based on status. Add an HTML Block and use the code below

<div id="mylink"></div>
<script>
if ([@authfield:Status] == "Completed"){
document.getElementById('mylink').innerHTML ="http://URL";
} else {
document.getElementById('mylink').innerHTML ="http://ANOTHER URL";
}
</script>
Link to comment
Share on other sites

  • 4 weeks later...

Thanks!  We weren't able to make it work exactly as above, but made this script get close to what we were looking for:

<div id="mylink">sometext</div>
<script>
if ("[@authfield:Status]" == "Active") {
    document.getElementById('mylink').innerHTML = "<a href=\"http://www.scheduledrelief.com/view-shift-details.html\">View details<a>";
} else {
    document.getElementById('mylink').innerHTML = "<a href=\"http://www.scheduledrelief.com/upload-documents.html\">Complete registration to submit bid<a>";
}
</script>

However, even though the test user is NOT "active", only the first row returns the "Complete registration to submit bid" results.  All subsequent results are the "sometext". 

Any suggestions?

 

Thanks!

 

screen shot.jpg

Link to comment
Share on other sites

Oh you need to change your code to

 

<div id="mylink[@field:UNIQUEID]">sometext</div>
<script>
if ("[@authfield:Status]" == "Active") {
    document.getElementById('mylink[@field:UNIQUEID] ').innerHTML = "<a href=\"http://www.scheduledrelief.com/view-shift-details.html\">View details<a>";
} else {
    document.getElementById('mylink[@field:UNIQUEID] ').innerHTML = "<a href=\"http://www.scheduledrelief.com/upload-documents.html\">Complete registration to submit bid<a>";
}
</script> 

Select the unique identifier from picker instead of " [@field:UNIQUEID] "

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
Reply to this topic...

×   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...
 Share

×
×
  • Create New...