Prefill a form checkbox from previous page url - forms

I am using the following code to automatically have one checkbox in a list of many prefilled when a button is clicked in a product page for more information.
This code is taken from a previously solved question, but it does not work for me. What am I doing wrong?
PAGE A (button)
More Information
PAGE B
$(document).ready(function(){
var hash = location.hash; //
f(hash=="#myHash"){
("#checkbox1").prop("checked", !$("#checkbox1").prop("checked") );
}
});
<input type="checkbox" id="checkbox1" name="boxset" value="XXXX">
Also PAGE A is a Wordpress page which automatically reverses the href for some reason.
<a id="select-checkbox1" href="pageB.html#myHash">More Information</a>
I have tried this in two other websites with the same problem. It obviously does not like the format.
I would appreciate some help with this.

Related

Form in one page button on other page how to perform this action?

I need to submit form for updating cart in magento so as to do that I have a button Update cart but the button should be in other page as per the PSD document now is that possible if I click button on this page and the action should be done which is in other page.
Please help me in doing this.
Oops I got the answer for this.
just followed this process.
<input type="button" value="Click Me!" onclick="submitForms()" />
submitForms = function(){
document.forms["form1"].submit();
document.forms["form2"].submit();
}

jquery ajax popup and return selected checkbox inside pop up form

Seems like a common question but could not find on this site. Must be due to my lack of experience in jquery or ajax.
I have a form like this:
<form id="form1">
+Add Item
</form>
when the person clicks "+Add Item" it pops up a new page which allows him to navigate and click the desired checkbox. Then it should insert in the above form something like:
<input type="hidden" name="item1_id" value="4">Item 1<br>
where value="4" would be the id of the checkbox checked.
any help would be greatly appreciated.
Don't use an anchor tag. Instead, create a div container for your pop up, which you can load dynamically:
$('#container').load('add-item.php');
Then add a listener to your item buttons append the result in your form:
$("#item_1").click(function() {
var $newinput = $("<input type='hidden' />");
$newinput.val(4);
$newinput.attr("name","item1_id")
$("#form1").append($newinput,"Item 1<br>");
});

How to make fancybox close after hitting "submit button"

My form comes from Hubspot and is embedded into a fancybox.
I would like the box to close as soon as the person hits "submit" but instead it redirects and stays open.
Secondly, I tried entering the code to clear the content box after submission but the old data stays in the fields after reopening.
How do I make the box close after they "submit"?
How do I code so that fields clear after each submission?
http://online.saintleo.edu/FancyBox2/FancyBox.html
In advance, thank you. You guys/gals are great.
After inspecting your Fancybox I found this html:
<form accept-charset="UTF-8" enctype="multipart/form-data" id="hsForm_bc762bf8-087a41ec-8f55-263df96f988a" class="hs-custom-form stacked hs-form" action="https://forms.hubspot.com/uploads/form/v2/206683/bc762bf8-087a-41ec-8f55-263df96f988a" method="POST" novalidate="novalidate">
It works as expected when I add target="_top" to it.
Your form.html may have a form tag. Add target="_top" to it.
See this link Link here
Add target="_top" in form tag
<form target="_top">

Show/hide Iframe

I am using wordpress for my website and I am trying to set up my pages so that a user has to click a button to view the content. Yes, very simple with show/hide etc but the button I Want the user to click is this http://www.facebook.com/plugins/like.php
To display that in my page i need to use an iframe which is where it gets tricky. I have set up the show/hide code so that when a user clicks the like button (or anywhere in the iframe) it will display the content. But, no such luck!
This is my code
<div id="imagebox" style="display:none;"><?php $image = wp_get_attachment_image_src(get_field('image'), 'full'); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php get_the_title(get_field('image')) ?>" /> </div>
<div onclick="ShowDiv()"><iframe src="http://www.facebook.com/plugins/like.php? href=http://www.facebook.com/BrandBang&" allowTransparency="true">
</iframe></div>
<script language="javascript">
function ShowDiv()
{
document.getElementById("imagebox").style.display = '';
}
</script>
I know that it is hard to use iframes to do what I am trying to do, but i am a total newbie when it comes to this stuff. Any help would be great!
Have tried giving your div an id="imagebox"?
EDIT:
This was already answered here.
But, I didn't realize at first sight that you're loading something in the iframe that is not coming from your own domain, so you're going to fall in a cross site scripting event, which is not allowed.
Afaik, you have to redesign some way your implementation.
For instance, you could retrieve the generated html from facebook using curl and then outputting in your own div. Something like that should work.

jqtouch go back after form submiting

I'm using jQtouch to build a page where the user can enter a kind of an ID and
get information (exam result) for this ID.
Because I take the results from the server, I used a form in the first page
with a text field and a submit button, and the action of this form send the user to the next page. Or at least, supposed to...
The problem is that also I'm being transferred to page with the results, and see the results properly, the Back button do nothing! BTW, in the address bar (above) I still see the name of the first page.
How can I go back to the "form" page? Thanks
<div class="current" id="byUserId">
<div class="toolbar">
<a class="back" id="goBack" > Back</a>
<h1> Exam Results</h1>
</div> ...
where the id="goBack" has a javascript:
$(function() {
$('#goBack').click(function() {
location.href = "enterId.jsp";
});
});
Using the regular back doesn;t work either:
<a class="back" href="#"> Back</a>
I now this is pretty late, but I had a similar frustrations and finally figured it out. The problem is that jQTouch intercepts all AJAX and form submit commands and safely send them itself. This isn't a problem except for when it's expecting some sort of callback, and there isn't one. In my case, I wanted to submit a form without a callback. To do this, look in the jqtouch.js library (around line 434) and comment out the following line:
if (href != '#') {
$.ajax({
url: href,
data: settings.data,
type: settings.method,
success: function (data) {
**// var firstPage = insertPages(data, settings.animation);**
This basically just tells jQTouch to submit the AJAX call but do nothing afterwards (don't change div's, don't show any callbacks and don't do any animations). Hope this helps.