Page 1 of 1

howto use hash cookies in iframe on subform?

Posted: Fri Jan 18, 2019 9:00 pm
by hf2094
Hello,
I have an HTML- field (defining an iframe) within a Subform based on a table containing fields with URLS. How can I use these URL in the embedded HTML/iframe?.

Definition of the HTML/iframe within the subform:

<iframe
width="560"
height="315"
src="#BILD#"
frameborder="0" allowfullscreen>
</iframe>

Whereas #BILD# is a Hash cookie from the subform.

Thank you for your help.

Hf2094

Re: howto use hash cookies in iframe on subform?

Posted: Sat Jan 19, 2019 8:15 am
by kev1n
Can you upload a screenshot showing the form and fields?

Re: howto use hash cookies in iframe on subform?

Posted: Sat Jan 19, 2019 9:15 am
by hf2094
Screen1 describes the edit form. On this form I use a subform (Screen2) with a HTML-Element, defined as Iframe. In this Iframe I want to display external graphic files, as defined in a separate table BildS:

CREATE TABLE `mineral_BildS` (
`idBildS` int(11) NOT NULL AUTO_INCREMENT,
`idStufe` int(11) NOT NULL,
`BildS` varchar(100) DEFAULT NULL,
PRIMARY KEY (`idBildS`),
KEY `fk_mineral_BildS_1_idx` (`idStufe`),
CONSTRAINT `fk_mineral_BildS_1` FOREIGN KEY (`idStufe`) REFERENCES `mineral_Stufe` (`idStufe`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

The edit form is based on table mineral_Stufe and the subform on mineral_BildS.

Using the nuBuilder file storage for storing pictures is not feasible, we need access tio the picture files for a piwigo-picture gallery.

Hope my english is not too weird.

Yours Hf 2094

Re: howto use hash cookies in iframe on subform?

Posted: Sat Jan 19, 2019 10:24 am
by kev1n
If you just have the hash cookie #BILD# in your html object you'll see that it doesn't get resolved. This means that you have to get to the value of that BILD field in another way, e.g. by using JavaScript and then change the src of the frame.

Code: Select all

<iframe
	id="iframebild"
	width="560"
	height="315"
	src=""
	frameborder="0" allowfullscreen>
</iframe>


<script>

$(function() {
 
   // testing: 
   // var imgURL = 'https://www.nubuilder.com/img/nubuilderfortelogo.png';
   var imgURL = $('#bild').val(); // replace #bild if the id is different
   $('#iframebild').attr( "src",imgURL);

});

</script>


Re: howto use hash cookies in iframe on subform?

Posted: Sat Jan 19, 2019 12:59 pm
by hf2094
Finally I found a solution based on your description of how to deal with iframe-IDs. Combined with our discussion some weeks ago about buttons on subforms I made it.

Greetings Hf2094