Question about attributes

User 122279 Photo


Senior Advisor
14,450 posts
Online Now

Working on something which I cannot get to work, not yet anyways. So just a silly question: I have something like this:

<img src="img_nature.jpg" alt="Nature" style="width:100%" onclick="myFunction(this);">

that I want to squeeze into SD3. That onclick bit, do I use an attribute and select 'Custom' to put it in? Just want to be sure I'm doing it the right way.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 379556 Photo


Registered User
1,535 posts

For onclick I use Custom, and have the name as onclick and the value as the function, each without any inverted commas. That last Vanilla menu thing I did uses onclick as an attribute, but puts the javascript directly in the value.

Frank
User 122279 Photo


Senior Advisor
14,450 posts
Online Now

Thanks! It was like I thought then. But still not working. I'll try a bit more, and if I don't get what I want, I'll ask you guys. ;)
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 379556 Photo


Registered User
1,535 posts

Knowing what's not the problem can sometimes be useful. This page from my messing about with toggling shows that the problem seems not to be with the entry in the Attributes. I put (without the inverted commas) 'onclick' as the name and 'myFunction(this)' as the value. It runs the simple script in the header, which may, of course, be seen via the source code in the browser, toggling the background colour of the container when one clicks on it.

Frank
User 122279 Photo


Senior Advisor
14,450 posts
Online Now

Yeah, it's certainly useful to know that the problem is NOT with the way I put the attribute. But you are saying you have the script in the header. I have mine in the footer. Could it be THAT that I'm doing wrong? Are certain scripts best placed in the header? I'm busy with something else right now, but I'll get back to the problem and maybe I'll have to pick your brain ;)
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 379556 Photo


Registered User
1,535 posts

This page seems to work equally well with the script in the footer. Hopefully someone knowledgable about Javascript will be able to help, as I think the problem must lie in the script.

Frank
User 244626 Photo


Registered User
811 posts

Inger wrote:
Yeah, it's certainly useful to know that the problem is NOT with the way I put the attribute. But you are saying you have the script in the header. I have mine in the footer. Could it be THAT that I'm doing wrong? Are certain scripts best placed in the header? I'm busy with something else right now, but I'll get back to the problem and maybe I'll have to pick your brain ;)


Inger, if you are trying to replicate the Tabbed Image Gallery (forgive me if I am mistaken) the problem with the example may lie in the fact the image tag gets wrapped in a picture tag in SD3 (and before versions). When this happens and you assign a id to the img tag, it actually gets assigned to the picture tag. In the script you are calling, it is suppose to copy the img src from the picture thumbnail to the main large picture img src. It runs into a problem though because the script is searching for the img tag with a certain id. That id is on a picture tag now and has no src to copy to.

If this is what you are trying to duplicate, there is another version that the script should work. You just have to supply both the thumbnail and the large pictures both.

https://www.w3schools.com/w3css/tryit.a … tors_image

Someone like Eric could probably figure out a fix for this version if in fact it is the one you are referring to.

https://www.w3schools.com/howto/tryit.a … mg_gallery

It would be a pretty neat component if you can get it to work !
Bootstrap 5 CSS Grid.
User 122279 Photo


Senior Advisor
14,450 posts
Online Now

Yes, Twinstream, you're right. I wanted to try that tabbed gallery. I had actually been looking at the original code and compared with the wrapping of the images in Sd3. I was thinking about posting a question about it directly to Bob, just wanted to be done with a couple of other tasks first. Now it is midnight here, so I'll have another go at it tomorrow.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 187934 Photo


Senior Advisor
20,188 posts
Online Now

Do you have a published page I can see or share a project?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 244626 Photo


Registered User
811 posts

I remembered Alter Eagle did something like this so I combined his work with the basic concept of the W3 example.

Its not refined in any way but the bare bones is there. Your welcome to it....

Thanks again Alter Eagle for the hard work and code....great stuff.

http://gordw.com/rsd/example/gallery.html
Attachments:
Bootstrap 5 CSS Grid.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.