Jump to content
Sign in to follow this  
DaeBo

How to enable Popup feature within JavaScript IF/ELSE links

Recommended Posts

I am using the JavaScript from this "Limit the Number of Submissions" article to display one hyperlinked image or another hyperlinked image based on meeting a condition. 

 

This is the original JavaScript from the article:

 

<script>
if([@field:Attendees] <[@field:Maximum_Attendees])
{
document.write("<a href='SubmissionURL&Course_ID=[@field:Course_ID]'> Signup </a>");
}
else
{
document.write("<p>Signup Closed</p>")
}
</script>

 

This is my modified version with image links instead of text links:

<script>
if([@field:Keyword_Count#] <[@field:Max_Keywords#])
{
document.write("<a href='URLwithPARAMETERS'><img src='IMAGEURL'></a>");
}
else
{
document.write("<a href='URLwithPARAMETERS'><img src='IMAGEURL'></a>")
}
</script>

 

Currently, when a visitor clicks on the image, the destination of the hyperlink is the same window. I would like the destination to be a popup window with resized window. I already use JavaScript popup code in another DataPage, so I figured I would paste and modify as so document.write("<a onclick="window.open(...); return false"><img></a>"), but this does not work. 

JavaScript popup code that works on another app, outside of the document.write("...").

<a onclick="window.open('URLwithPARAMETERS','popup','width=550,height=200, scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=50,top=50'); return false"><img alt="Delete" src="IMAGEURL" style="width: 20px; height: 20px; margin: 1px;" /></a>

 

Any recommendations?

Share this post


Link to post
Share on other sites

Try this one then:

 

<div id="MyLink[@field:UniqueID]"></div>
<script>
if([@field:Keyword_Count#] <[@field:Max_Keywords#])
{
document.getElementById("MyLink[@field:UniqueID]").innerHTML = '<a onclick="window.open(\'URLwithPARAMETERS\',\'popup\',\'width=550,height=200, scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=50,top=50\'); return false"><img alt="Delete" src="IMAGEURL" style="width: 20px; height: 20px; margin: 1px;" /></a>'
}
else
{
....
}
</script>

 

<div id="MyLink[@field:UniqueID]"></div>
<script>
if([@field:Keyword_Count#] <[@field:Max_Keywords#])
{
document.getElementById("MyLink[@field:UniqueID]").innerHTML = '<a onclick="window.open(\'URLwithPARAMETERS\',\'popup\',\'width=550,height=200, scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=50,top=50\'); return false"><img alt="Delete" src="IMAGEURL" style="width: 20px; height: 20px; margin: 1px;" /></a>'
}
else
{
....
}
</script>

Select [@field:UniqueID] from picker and it should be a unique field in your table

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...