I've been searching endlessly on the internet for a way to attach an image to an html form onclick(). Is this something that's possible? I have a webpage created that displays images and I want specific images to be attached to the HTML form page when clicked so that it can be emailed to me once the form is submitted. I just need a sample code and I will take it from there. Thanks.
Related
I know this is a bit tricky because I can't actually post the JS or HTML code but I'll try my best to describe it.
So basically I created a table with JS on the HTML.
Then I use "submit" and "form" in the html to submit content onto the table. The content is retrieved with fetch and an API.
The issue I have is that while it all works well, the data doesn't appear on the table without me having to refresh the browser. I'd the data to appear as soon as I click the submit button.
Cheers and thanks in advance
Its obvious and correct to dont show new records because table just can show last result of request .
For your goal you can reload just table tag with ajax or other ways for example you can refresh table tag x second after click on submit button.(x should be enough big that new records has time to submit).
For a requirement, I have a iframe in my html page like this
<iframe src="www.abc.com" id="firstembed" name="iframebox"></iframe>
So, the given URL (www.abc.com) will get loaded in the iframe. Now, my requirement is, if user click on the area of iframe(for ex: image or dropdown etc), I need to display the alert message containing name, id or text etc.
Please advice me how we can detect the click event on iframe element using JQuery.
So I'm pasting in some code for a form from Salesforce.
This code to be specific: (from the style element to the end of the form) https://gist.github.com/13ab0efd07c2c8cdb3e1
When clicking submit while not filling out any or all fields, I get a form validation check and then a message will popup with the fields that I have not filled out.
However, when I paste the code into our LightCMS template the form validation is not working and just redirects to the thankyou page as if everything went through fine.
They use LightCMS. And even when link to an external js file instead of embedding the js I still get the same results.
I've noticed it adds an "onclick" element on the Submit button on the front-end but it only does that when it's in the CMS not on a bare bones HTML page.
Any thoughts?
i think you should add this
onsubmit=return formvalidator(Document.getElementByid(search-form))
before form action because it will check the form before submitting it. if check fails the action will not occur.
I have a JS photo gallery that loads individual images from an API into the page when users click a thumbnail. I'd like people to be able to add Facebook comments on each image. So I've got my Facebook comments element in the page that contains the gallery.
<div class="fb-comments" data-href="" data-num-posts="10" data-width="480"></div>
On loading the page and first populating the gallery I set the data-href attribute of the comments element to the URL for the first image (for example http://site.com/gallery/1027/1). Then if the user clicks on a thumbnail I reset that attribute to the URL for the selected image.
fbComments.attr('data-href', data.link + index);
FB.XFBML.parse();
The FB.XFBML.parse(); is what I've read you're supposed to do to get Facebook to refresh the comments. I've added a comment to one image and tried clicking on the thumbnail for an image without a comment. But my comment for the first image is still there. Can anyone suggest why?
I've tried logging out the FB object in my JS file, and it logs OK, so it is available at the point I call it. I've checked that the click event in my JS is indeed changing the data-href attribute to the right value. And when I hardcode a different data-href in the fb-comments element the comments render as expected.
I suggest that you completely remove the previous comments box from the dom, then insert a new html with the right data-href and then call the FB.XFBML.parse method.
Another thing is that you should specify where to parse, like so:
FB.XFBML.parse(document.getElementById("container-id"));
Im a bit of a noob to jquery and js so ill try be as informative as I can.
I am using facebox on my page and a link which opens facebox which in turn loads an iframe inside calling a source page for the iframe window.
Loaded into the iframe then is a page which contains a form. The form validates via script thats attached to the parent window calling the iframe & facebox. The validating works but what i want to do is pass a variable back to the iframe window upon validation.
The form i refer to asks the user to create a new photo album which then appends to a select box once created as indicated here: (ill keep it brief)
var albumname = form.albumname.value;
$(""+albumname+"").appendTo('#als');
document.getElementById('albumname').value='Enter a name for a photo album';
Can anyone tell me how to pass this correctly to the iframe window?
Everything else works including the last line of code that resets the album name text input field.
Many thanks in advance,
Wayne
If you want to manipulate the contents of your iframe you can use a selector similar to this.
$("div", nameOfIframe.document)
What you need to remember is that your iframe need to be in the same domain as your main page, or else it won't work.