Sending form data without updating the HTML - javascript

I'm using jQuery/JavaScript to append my cart items into the checkout form and
item_name_x, amount_x are dynamically generated.
<input type="hidden" name="item_name_1" value="Orange">
<input type="hidden" name="item_name_2" value="Apple">
<input type="hidden" name="item_name_3" value="Pineapple">
<input type="hidden" name="amount_1" value="260">
<input type="hidden" name="amount_2" value="140">
<input type="hidden" name="amount_3" value="600">
Here is what it will look like in the browser's developer tool.
Whenever I check or uncheck an item, the HTML within the developer tools will update accordingly. Is there a way to prevent the developer tools from updating but still be able to send through data?

Related

Fetch form variables in node

After making a request to URL I get a HTML page as a response.THe responded page consists of a form of whose variable I want to fetch.
Output
<input type="hidden" name="Flag_CustomerStatus" value="1">
<input type="hidden" name="Flag_InstantPayment" value="" />
<input type="hidden" name="txtMerchNum" value="90">
<input type="hidden" name="txtHttp" value="http://www.mywebsite.com/ThankYouPage.php">
<input type="hidden" name="txtMerchRequest" value="add_cc">
<input type="hidden" name="action" value="">
<input type="hidden" name="IsPostBack" value="True">
<input type="hidden" name="Lng" value="en">
I am familiar with Php and I can extract these variables using $_POST['Flag_CustomerStatus'] but I am not able to parse them when implemmenting in Node Js.
Kindly suggest
after you get success ajax result - you can write this html to other div
like this
<div style='display:none;' id='hidden_div'>
....
....
$('#hidden_div').html(your_html);
after it you can choice any value by JQuery from any hidden input
Or second solution is - you can change php side
and get array with values, after it - you can generate HTML

Always seeing the old PayPal Express Checkout interface in Ionic/Cordova

I want to implement PayPal Express Checkout the easy way into my Ionic/Cordova app.
I've created a template (paypal.html) which basically just holds the following lines:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal-checkout-form">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="J4N...9PU" />
<input type="hidden" name="amount" value="1.99" id="paypal_amount" />
<input type="hidden" name="shipping" value="0.00" />
<input type="hidden" name="button_subtype" value="services" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="lc" value="DE" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input type="hidden" name="return" value="http://www.example.com/some-page-to-return-to" />
</form>
In my controller I open this template with the inAppBrowser of Ionic, and inject a basic javascript function which submits the paypal-checkout-form, like that:
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
$cordovaInAppBrowser.executeScript({
code: 'var paypalFrm = document.getElementById("paypal-checkout-form"); paypalFrm.submit();'
});
});
I've implemented it that way as I don't have to handle a get_token script from my PHP-Server or any other PayPal requests.
Problem I face now is that not the good-looking new PayPal interface is showing up (just the old gray one), and that the viewport is blown up (the full-fledged PayPal checkout page is shown, not a responsive one).
Is it possible to force to display the new interface? On my computer (same code) everything works as expected.
Thank you.

Auto fill form with URL not working

I was trying to write a bit of javascript to go to a website with the form data already filled in.
This is the HTML for the site:
<form action="/transfer-request" method="post">
<input name="_csrf" value="PcZhHftj-GInv-7mCqMprPOA_aK2HERs1G10" type="hidden">
<label for="amount">Coins</label>
<input id="amount" name="amount" placeholder="100" min="10" step="1" required="" type="number">
<label for="to-user">Recipient User</label>
<input id="to-user" name="to-user" required="" type="text">
Back
<input class="button right" type="submit">
<input name="transfer-id" value="3344847d-1824-48e1-b156-8debd677a672" type="hidden">
</form>
Assume site is on www.example.com/transfer
I have tried modifying the URL as follows:
www.example.com/transfer?amount=25
Without any luck. Am I doing this wrong? Should this not auto fill the amount field to 25, is there a way the website is preventing me from auto filling it, or an alternative way (either through URL or javascript only) that I can accomplish this?

Logging into https://www.amazon.com/ap/signin with PhantomJS

Maybe I am making this more complicated then I need to. I am learning about Phantom JS I figured I could use that to automate Android App submissions to the Amazon App Store/Amazon Developer Console. The login page has this URL: http://developer.amazon.com/home.html
It redirects to a super long URL and presents a form to enter one's username and password and a button to click. If you look at page source you see a form that has all sorts of hidden inputs. Here is the part of the actual form tag from the page source:
<form name="signIn" method="POST" id="ap_signin_form" novalidate="novalidate" action="https://www.amazon.com/ap/signin" onsubmit="var test1 = apCheckRequiredFields('ap_signin_form', ['ap_email','ap_password']);
return (apValidateEmail('ap_email') && test1);">
<input type="hidden" name="appActionToken" value="scIhj2FOCtxr39z7eUIj2FWeNOWxtIwj3D"><input type="hidden" name="appAction" value="SIGNIN">
<input type="hidden" name="openid.pape.max_auth_age" value="ape:MQ==">
<input type="hidden" name="openid.return_to" value="ape:aHR0cHM6Ly9kZXZlbG9wZXIuYW1hem9uLmNvbS9hcF9sb2dpbi82ODc0NzQ3MDczM0EyRjJGNjQ2NTc2NjU2QzZGNzA2NTcyMkU2MTZENjE3QTZGNkUyRTYzNkY2RDJGNjg2RjZENjUyRTY4NzQ2RDZDLmh0bWw=">
<input type="hidden" name="prevRID" value="ape:N1RBVEM3SFQxSEdXRTNITUFENEs=">
<input type="hidden" name="openid.identity" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=">
<input type="hidden" name="openid.assoc_handle" value="ape:bWFzX2Rldl9wb3J0YWw=">
<input type="hidden" name="openid.mode" value="ape:Y2hlY2tpZF9zZXR1cA==">
<input type="hidden" name="language" value="ape:ZW5fVVM=">
<input type="hidden" name="openid.claimed_id" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=">
<input type="hidden" name="pageId" value="ape:bWFzX2Rldl9wb3J0YWwy">
<input type="hidden" name="openid.ns" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA=">
<div id="ap_signin1a_pagelet" class="ap_table ap_pagelet">
<div id="ap_signin1a_pagelet_title" class="ap_row ap_pagelet_title">
<h1>Sign In </h1>
</div>
<div id="ap_signin1a_email_section_title" class="ap_row ap_section_title">
<h2>
What is your email (phone for mobile accounts)?
... even more html here ...
I am kind of confused about what I am suppose to do with the Phantom JS code. Do I need to collect all these hidden inputs and build a form data object to send in a POST request? Or do I just need to figure out what DOM objects I need to set to my my credentials and then generate a button click event?

Submit via javascript doesn't send the textbox value

Interesting problem. I have a client who wants the add to cart button to be an image. That's fine, submit via javascript in an onclick on the image. But when I look at the values being sent, quantity is always 1 (or whatever I set it as in the code). In other words, I can't change the value of quantity.
<form name="AddToCartForm<?=$index?>" id="AddToCartForm<?=$index?>" action="[cartaddress]" method="post">
<input type="hidden" value="1" name="insert" />
<input type="hidden" value="<?=$subcategory['Name'];?>" name="category" />
<input type="hidden" value="<?=$item['ProductNumber'];?>" name="prodnumber" />
<input type="hidden" value="<?=$item['Name'];?>" name="prodname" />
<input type="hidden" value="<?=$item['Price'];?>" name="prodprice" />
<input type="hidden" value=".10" name="handling"/>
<input type="hidden" value="10" name="weight" />
<p><?=$item['Description'];?></p>
<p><strong>Quantity:</strong> <input type="text" name="quantity" size="10" value="1"/></p>
<p><strong>Price:</strong> $<?=number_format($item['Price'], 2);?></p>
<p>
<img onclick="document.getElementById('AddToCartForm'+<?=$index?>).submit();" style="cursor:pointer;" src="images/cart_button.png" width="100" height="111" alt="add to cart" />
</p>
</form>
(If I use a submit button, the quantity goes through.)
You can use <input type="image"> instead of <img>. It acts like submit button.
Your onlcick merely submits, it doesn't do anything to change the value of quantity...so it's doing what you told it to. Before submitting you need to read the value of quantity, add 1 to that, and write the new value back to quantity.
Although the solution is already given, I think I got the cause of the problem:
document.getElementById('AddToCartForm'+<?=$index?>).submit();
I think the 'onclick' submits the wrong form. Would it also work if you changed it to document.getElementById('AddToCartForm<?=$index?>').submit();?

Categories

Resources