I'm trying to run a script that clicks on two seperate buttons/Ids on the same website.

I want to run first

document.getElementById("add-to-cart").click()

which will redirect me to the cart/basket page of an online store
once I'm there, i want to run

document.getElementById("checkout").click()

which will take me to paypal.

How do I incorporate these two together?
Please help when you can, Thanks

1 What if the USER wants to buy two: can't be done if you click programmatically

2 Paypal terms of service: Paypal get upset at a site that bypasses required user confirmation

ANY dispute, you lose

I just want to click on the "add-to-cart" button because the page only has ONE product available. Once it gets added it directs to the CART/Basket page. which has the option to Checkout (Which will LATER take me to paypal but not right after I click it) How do I do this?

I'm wondering the reason for even have a "cart" when you only have one product. Wouldn't it make it a lot simpler to just have a "buy now" button that takes them off to Paypal to pay for it? I wouldn't use a cart at the grocery store for one loaf of bread.

I know, but this is for a site that sell shoes ever week and these shoes are sold by people bringing in their shoes. Just like a flightclub if you have heard about them. I'm just a novice and learning how to use javascript. Any help is apreciated. I am confused on how I can run/have both of those scripts on the same site. I am using a chrome extension that runs whatever script i give to it. It does not allow a script to run on a certain specific page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.