form not posting to iframe back - javascript

This should have been pretty simple but I have spent a few hours trying to figure out why a simple form post would not end up in the iframe instead of a new window.
I am trying to post data to authorize.net and I want the reponse to be back in the iframe. However it opens a new window. I am not sure what else to do. here is my code
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
document.getElementById("test-form").submit();
});
</script>
</head>
<body>
<form method="post" name="test-form" id="test-form" target="myIframe" action="https://test.authorize.net/gateway/transact.dll">
<input type="text" name="x_login">
<input type="text" name="x_fp_sequence">
<input type="text" name="x_fp_timestamp">
<input type="text" name="x_amount">
<input type="text" name="x_fp_hash">
<input type="text" name="x_show_form">
<input type="text" name="x_test_request">
<input type="text" name="x_type">
<input type="text" name="x_currency_code">
<input type="text" name="x_invoice_num">
<input type="text" name="x_description">
<input type="text" name="x_first_name">
<input type="text" name="x_last_name">
<input type="text" name="x_company">
<input type="text" name="x_address">
<input type="text" name="x_city">
<input type="text" name="x_state">
<input type="text" name="x_zip">
<input type="text" name="x_country">
<input type="text" name="x_phone">
<input type="text" name="x_email">
<input type="text" name="x_relay_response">
<input type="text" name="x_solution_id">
</form>
<iframe src="" name="myIframe></iframe>
</body>
</html>

By putting your code in Plunker, there is a syntax error at line 37:
<iframe src="" name="myIframe></iframe>
^-- missing "
After adding the closing quote, I can see the page loaded in the iFrame :)
https://embed.plnkr.co/aM5EsESHODV8nPbVhyK8/
You may want to consider changing to use an IDE which may help you identifying typos, so that hours can be saved.

You are missing double quotes at the end of the iframe name.

Related

Form GET method drop link instead of redirect

I want to remake my payment form. I'm using GET method, and want to return link below form instead of redirect, after clicking submit. Someone have any idea?
<script type="text/javascript">
function formatMoney(e) {
document.getElementById('z24_kwota').value = (!isNaN(e.target.value) ? e.target.value : 0) * 100
}
</script>
<form method="get" id="myform" action="https://sklep.przelewy24.pl/zakup.php">
<input type="hidden" name="z24_id_sprzedawcy" value="000000">
<input type="hidden" name="z24_crc" value="000000">
<input type="hidden" name="z24_return_url" value="https://google.com">
<input type="hidden" name="z24_language" value="pl">
Tytuł wpłaty
<input type="text" name="z24_nazwa" id="pole" maxlength="30" value="" placeholder="Wprowadź tytuł wpłaty" required>
<br>
<input type="hidden" name="z24_kwota" id="z24_kwota">
Kwota wpłaty
<input type="text" id="pole" placeholder="Wprowadź kwotę wpłaty (PLN)" pattern="^([1-9])((\.\d{1,2})?)$|^((?!0)(\d){1,5})((\.\d{1,2})?)$|^(1(\d{5})(.\d{1,2})?)$|^(200000(.[0]{1,2})?)$" onkeyup="formatMoney(event)" required>
<br>
<BR>
<input type="submit" class="przycisk" value="zapłać teraz">
</form>
I checked all Internet, and can't find any solution

Open 3 different google searches by one click

I´m looking for a way to run three google searches with three different keywords by one click.
Here´s what I got so far:
<form action="https://google.com/search" method="get" target="_blank">
<input type="text" id="q1" name="q" placeholder="first" required /><br>
<input type="text" id="q2" name="q" placeholder="second" required /><br>
<input type="text" id="q3" name="q" placeholder="third" required /><br>
<input type="submit" value="Google Search" />
</form>
It opens a new tab with a google search for all three keywords.
But I want it to open three different tabs/sites/frames... each one with a search for one keyword. I guess there´s a way to solve this problem with js but I know almost nothing about java script.
I need something like:
onsubmit = window.open("search1"); window.open("search2"); window.open("search3");
Hope you can help me.
Greetz
function openNewTab(url){
var redirectWindow = window.open(url, '_blank');
redirectWindow.location;
}
document.getElementById("asd").addEventListener("click", submit);
function submit(){
var a = document.getElementById('q1').value;
var b = document.getElementById('q2').value;
var c = document.getElementById('q3').value;
var url = "http://google.com/search?q=";
openNewTab(url+a);
openNewTab(url+b);
openNewTab(url+c);
}
<form>
<input type="text" id="q1" name="q" placeholder="first" required /><br>
<input type="text" id="q2" name="q" placeholder="second" required /><br>
<input type="text" id="q3" name="q" placeholder="third" required /><br>
<input type="submit" id="asd" value="Google Search" />
</form>
Well this is entirely based on user's browser settings whether he allows to open new tabs by scripts or not. Above code will only work if Popups are allowed in browser. I see no other way to sort it out
To test on your browser (Assume you're running chrome) , you can change settings here chrome://settings/content/popups in your browser and allow popups
I´ve got a solution... not very elegant but it works (sort of).
<form id="form1" action="https://google.com/search" method="get" target="_blank">
<input type="text" id="q1" name="q" placeholder="first" required /></form><br>
<form id="form2" action="https://google.com/search" method="get" target="_blank">
<input type="text" id="q2" name="q" placeholder="second" required /></form><br>
<form id="form3" action="https://google.com/search" method="get" target="_blank">
<input type="text" id="q3" name="q" placeholder="third" required /></form><br>
<button onclick="document.getElementById('form1').submit();
document.getElementById('form2').submit();
document.getElementById('form3').submit();"> Search </button>

Auto-complete input2 with the value from input1

On page 1.html I have this form:
<form id="my_form" action="2.html">
<input type="text" id="input1" value="" />
<input type="submit" />
</form>
After the user presses the button he is redirected to 2.html. On this page I have this input:
<input type="text" id="input2" value="" />
How can I get input2 "auto-completed" with the value inserted by the user in input1 ?
Tried this:
Changed 2.html to 2.php and <input type="text" id="input2" value="" /> to <input type="text" id="input2" value="<?php echo htmlspecialchars($_POST['input1'])?>" /> - no luck
Different approaches using sessionStorage - no luck.
I must be missing something simple, please help...
In the form on page 1.html you didn't provide a submission method. Try changing it to
<form id="my_form" action="2.html method="POST">
<input type="text" id="input1" name="input1" value="" />
<input type="submit" />
</form>
The reason your script is not working is because #input1 is missing name attribute .. try changing html of #input1 to this :
<input type="text" id="input1" name="input1" value="" />
Also, you were not declaring any method on form, by default if the method is not declared then it is set as GET. As you are getting values on second page by POST, declare form method to POST.
So, the html of form will be:
<form id="my_form" action="2.php" method="POST">
<input type="text" id="input1" name="input1" value="" />
<input type="submit" />
</form>

Password validation (2 Textboxes, comparision)

before you blame me, yes I was looking for something similar for about a hour, but sadly I couldn't find my error, atleast the Questions I was looking for in stackoverflow didn't gave me a correct answere, as I have almost exactly the same thing (not Copy and Paste).
However could someone explain me, why my code (javascript) isn't working?
I am playing around with it for some hours now but I can't find it.
<html>
<head>
<title>Anmeldung/Login</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<script>
function abc(){
var a = document.getElementById('pw').value;
var b = document.getElementById('repw').value;
if(a==b){
alert(yes)
}
}
</script>
</head>
<body>
<div id="banner">
<p>NAME/ÜBERSCHRIFT</p>
</div>
<form id="loginpanel">
<fieldset>
<legend>LOGIN</legend>
<p class="textinput">Benutzername: <input name="id" type="text" size="30" maxlength="30"></p>
<p class="textinput">Passwort: <input name="pw" type="password" size="30" maxlength="15"></p>
<input class="button" type="button" name="login" value="Anmelden"/>
</fieldset>
</form>
<p id="option"> ...oder Registrieren!</p>
<form id="registerpanel">
<fieldset>
<legend>REGISTER</legend>
<p class="textinput">Benutzername: <input name="id" type="text" size="30" maxlength="30"></p>
<p class="textinput">eMail: <input name="email" type="text" size="30" maxlength="30"></p>
<p class="textinput">Passwort: <input name="pw" type="password" size="30" maxlength="30"></p>
<p class="textinput">Passwort wiederholen: <input name="repw" type="password" size="30" maxlength="30"></p>
<input class="button" type="button" onclick="abc()" name="register" value="Registrieren"/>
</fieldset>
</form>
</body>
I would be happy if someone can give me an answere!
Thank you for taking your time :)!
You must have inputs with id attribute with values pw+repw. Having only a name attribute will not work
example: <input name="repw" id="repw" type="password" size="30" maxlength="30">
Corrected version (only relevant parts):
<script>
window.abc = function(){
var a = document.getElementById('pw').value;
var b = document.getElementById('repw').value;
if(a==b){
alert("yes")
}
}
</script>
...
<form id="registerpanel">
<fieldset>
<legend>REGISTER</legend>
<p class="textinput">Benutzername: <input name="id" type="text" size="30" maxlength="30"></p>
<p class="textinput">eMail: <input name="email" type="text" size="30" maxlength="30"></p>
<p class="textinput">Passwort: <input name="pw" id="register-pw" type="password" size="30" maxlength="30"></p>
<p class="textinput">Passwort wiederholen: <input name="repw" id="register-repw" type="password" size="30" maxlength="30"></p>
<input class="button" type="button" onclick="abc()" name="register" value="Registrieren"/>
</fieldset>
</form>
Note the added IDs. I didn't do pw and repw because having plain pw in login made more sense to me (11684) (don't forget to add that in the login form). Because I'd do register-pw I went for consistency and did register-repw. But it doesn't matter what these IDs are as long as they are unique.
And I changed the typo alert(yes) into alert("yes") because obviously the first throws a reference error.
A working JSFiddle: http://jsfiddle.net/7NZUc/

IFrame form submittal opens in frame, needs to open in new window

Trying to resolve an issue using a 3rd party form that unfortunately has to use an iframe to be embedded in the article content. When a user submits their email address, the thank you page opens up in the space taken up by the iframe instead of the page / a new window. I tried using the following JS script to no avail:
<script type="text/javascript">
// If "&_parent=URL" is in this page's URL, then put URL into the top window
var match = /_parent=(.+)/.exec(window.location.href);
if (match != null) {
top.location = match[1];
}
</script>
The page in question:
http://restoringqualityoflifeblog.org/subscribe/
Thanks!
From https://help.salsalabs.com/entries/21689130-Embed-a-signup-form
Here is the form you need by itself with [] indicating the keys you need for it to work.
<form action="[[API URL]]/save" method="POST">
<input type="hidden" name="organization_KEY" value="5881"/>
<input type="hidden" name="chapter_KEY" value="887"/>
<input type="hidden" name="email_trigger_KEYS" value="12644,12656"/>
<input type="hidden" name="object" value="supporter"/>
<label for="first_name">First Name:</label><input type="text" id="first_name" name="First_Name"/></br>
<label for="last_name">Last Name:</label><input type="text" id="last_name" name="Last_Name"/></br>
<label for="email">Email:</label><input type="text" id="email" name="Email"/></br>
<style>.memberCode{display:none;}</style>
<div class="memberCode"> Optional Member Code <input name="first_name_949" value=""/></div>
<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="11"/>
<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="12"/>
<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="13"/>
<input type="hidden" name="tag" value="excellent"/>
<input type="hidden" name="redirect" value="http://YOUR URL">
<input type="Submit" value="Sign up" />
</form>
You already have a working copy of the form here:
http://salsa3.salsalabs.com/o/50047/p/salsa/web/common/public/signup?signup_page_KEY=8896

Categories

Resources