Expand my Community achievements bar.

imageField.value.image.href?

Avatar

Former Community Member
What method can I use to allow the user to change the value of the URL property of an image field from one URL to another via a drop down?



I have a drop down that uses a JS if/then to change the value of the image field URL. However, when testing the form, making a selection in the drop down does not change the URL of the image field. I've used drop downs with JS to change other properties of an image field (such as presence.)



Is imageField.value.image.href the proper way to identify the URL property?



I've tried asking this question several different ways but still no indication as to whether or not this is even possible with LiveCycle.
22 Replies

Avatar

Former Community Member
Hi Ivan,



Try this script:



imageField1.value.image.href = "http://www.yourwebsite.com/yourpicture.jpg";



Your users will receive an Adobe security warning as it connects to your image. They can click through the message and eliminate the message in future by checking to remember the action for that site.



I found this tip in J.P. Terry's new book "Creating Dynamic Forms with Adobe LiveCycle Designer". A very worthwhile purchase. Note: the book is currently available at www.peachpit.com.



Have a great day!

Pam

Avatar

Former Community Member
here's my code:



----- typ_2-7.sf_main.sf_fieldGroup.sf_northArrow.northArrow::change: - (JavaScript, client) -------



var dir = xfa.event.newText;

if (dir == "North") {

northArrowT.value.image.href = "http://a642.ac-images.myspacecdn.com/images01/86/l_832e900ad483303dc49636745590ebd9.jpg";

}

if (dir == "South") {

northArrowT.value.image.href = "http://a935.ac-images.myspacecdn.com/images01/65/l_88e61f1d39f9fa3d4ffe94b73097bf66.jpg";

}

Avatar

Former Community Member
Hi Ivan,



I spent a few hours working on your scenario.



I had the same results you had by trying to change the url location.



I tried alternatives... such as...



Created two subforms (SubformNorth and SubformSouth). I added an image box for each subform. I pointed to URL for the north image box on SubformNorth and the south image box on the SubformSouth. I set the presence of both subforms to Invisible. I created a RadioButton Group with two buttons. One labeled North and one labeled South. On the "Change" event of the RadioButton Group I have the following java script:



var oSelect = xfa.resolveNode("form1.#subform[0].newText")

if oSelect = "1"{



----- form1.P1.RadioButtonListDir::click: - (JavaScript, client) -----------------------------------



if(this.rawValue=="1")

{

SubformNorth.presence="visible";

SubformSouth.presence="hidden"

}

else

{

SubformNorth.presence="hidden";

}

if(this.rawValue=="2")

{

SubformNorth.presence="hidden";

SubformSouth.presence="visible"

}

else

{

SubformSouth.presence="hidden";

}



This scenario works perfectly.



My second scenario was with a listbox as you were attempting. The problem I had with it was I had to click out of the box and back in before the image would appear.



Sorry I was able to solve the url issue. But here is a viable workaround.



Have a super day.

Pam

Avatar

Former Community Member
Thanks Pam, that's a big help. I'm trying to create these forms with the smallest file size possible. I could just embed everything and then use visible and invisible presence to turn things on and off but the scope of this project would make that a 1GB or larger file! eek! However, I could write a very long script that turned images on and off that were linked instead of embedded. That would eliminate the massive file size issue but that's a lot of code... it could work and from what I can tell it may be my only option.

Avatar

Former Community Member
Ivan,



I didn't check the mark to embed the images. They were pulling from the url. So it shouldn't bloat the file.



Thanks

Pam

Avatar

Former Community Member
Thanks again, Pam :) It works really good. I just wish I could find a way to actually change URLs... There's got to be a way to make this happen...

Avatar

Former Community Member
Ivan,



Will you test something for me on your system in a new blank form?



I want you to add an image field but do not define a url to it and do not preview the form.



Then add the javascript below to the form:ready event.



b ImageField1.value.image.href = "http://a642.ac-images.myspacecdn.com/images01/86/l_832e900ad483303dc49636745590ebd9.jpg"



You should see your image in the image field on the form. Remember don't preview from Designer.



Save your document using "Acrobat 7 (Static) PDF" format. Close out of designer. Open the file in Acrobat Professional. Do you see the image? Close file from Acrobat Professional. Re-open the file in designer. Is the image checked embedded?



Mine isn't checked as embedded. What version designer are you running?



Please let me know your results.



Thanks

Pam

Avatar

Former Community Member
Thanks Pam. This works great. I'm using v8. This gets me one step closer. Now I can at least use visble/invisble to change images and they won't be embedded. Now, if I can just figure out how to get the URL to change... :) Thanks very much for your help, Pam. Awesome!

Avatar

Former Community Member
Ugh... the frustration continues.



I've applied your technique, Pam, to my form. If I save it as a static form, my linked images show up and I can can change their presence. Cool.



However, I've now created a new problem!



On another part of my form, I have a drop down that changes the presence of a sub-form. This doesn't work as a static form, but when I save it as a dynamic form, my image presence drop down doesn't work anymore!

Avatar

Former Community Member
Hi Ivan,



My troubleshooting technique was to determine when the image was getting embedded in your form and what Events the "href" syntax works. So we've proven the "href" works for the Form:Ready event. At this point the form design and data are merged, the finished form exists in memory and the initialize, calculate and validate events have completed.



This morning I was able to save my test form to dynamic 7 xml format and it still showed the image from the web page without embedding itself in the XML. In your existing problematic form did you try deleting the imageField you originally created and adding a new one?



From what I've read within Designer's Help, on the ImageField object, it is

b intended

for use within Dynamic forms. However, I can see this could be a problem for Acrobat users using the form offline, with no internet access, or behind a firewall.



Also, this is what Help says regarding embedded feature of the ImageField object.

"When you embed the image in the form, a copy of the image information is stored in the form. If the image field will be used to load images dynamically when the form is rendered, do not select the Embed Image Data option."



I am continuing to research what events are available for the ImageField.



Have a great day!

Pam

Avatar

Former Community Member
Hi Ivan,



Is embedding the image in your form an option? If so, have a look at the example posted on the Developer Center at



http://www.adobe.com/devnet/livecycle/designer_scripting_samples.html



Look for the sample titled: "Display different images inside the same image field".



Regards,



Hélène

Adobe Systems

Avatar

Former Community Member
Helene,



Glad to see an Adobe System Support Team member responding to our thread!!!



From a drop-down list Ivan wants to change the ImageField href to point to different images. He doesn't want the images embedded. Plus the form must be Dynamic.



What "Events" would be available for the ImageField href parameter?



Thanks

Pam

Avatar

Former Community Member
Ah yes, I didn't click on 'Show All Messages' : )



One question, which version of Designer and Acrobat should this form work in? The script Ivan provided earlier works fine for me with Designer 7.1/Acrobat Pro 7.0.



As for the event, it is best to use the 'change' event with a drop-down list.



Hélène

Adobe Systems

Avatar

Former Community Member
Back from a wild weekend.



I'm using Designer 8 but I've saved as PDF in both 7 and 8 but it still does not work. I'd be willing to use an older version if it will do what I want.



At this point I need to have some results so I've begun building multiple PDFs with limited dynamic elements using a template. It will be a lot more tedious but at this point it's my only solution.



Does anyone know of another tool I could use to create this? I easily design the whole this in HTML and PHP but output is a problem. Printing from a browser isn't an option. It is very much a web-page type of this but it needs to have print-quality output.

Avatar

Former Community Member
Ivan,



I was experiencing the same issue with setting dynamic image urls. I was seeing the problem when attempting in Reader 8.1. Then, I tried in Acrobat 7, and the issue was resolved.

Avatar

Former Community Member
After getting the dynamic href url to work, I am interested in embedding the image within the pdf. So, if I had a url pointing to a local file and I deleted the file or if I pointed to a file on the web and disconnected the network, the image would still show in the pdf after I have saved it.



Is it possible to embed images in the pdf on the fly like this?

Avatar

Former Community Member
We are having the same problem with both Image Fields and Images. When we set the URL from an initalize event the image will never display under Reader 8.1. The image displays perfectly fine under Reader 7.x. With some of the new features we are using in Reader 8.x, we do not have the option also use Reader 7.



The logic we are using for changing the URL's are:



ImageField:initalize (Javascript,Client)

this.value.image.href = xfa.dataWindow.record(0).LogoPath.value;



Subform:initalize (javascript,Client)

xfa.resolveNode("MyLogo").value.image.href = xfa.dataWindow.record(0).LogoPath.value;



I realize I could use a direct reference on the subform but that does not change the fact the image does not display.



Has anyone found an issue for dynamic URL's and Reader 8.1 or are there any patches available.

Avatar

Former Community Member
I've been able to get this to work in Acrobat Pro 8.0.0 and 7.0.9 by using "http://" instead of "file://" for the href value. The local file system worked on earlier versions of 7, but once I installed the updates, it stopped working. It may have been a security update somewhere along the way that's preventing using the local file system.

Avatar

Former Community Member
There was a security update between Reader 8.0 and 8.1 that stops the href property being dynamically updated via Javascript.