Thassa
Thassa

Reputation: 542

Trying to get a button to work as a submit button

I am trying to figure out how to make this HTML submit button work correctly. Below is the code for the submit button:

<form action ="itms-services://?action=download-manifest&url=https://icustomer.apsresource.com/ipad_apps/survey/user/APSSurvey.plist">
    <button type="submit" name="Download" value="download" onclick="JavaScript:alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.')" style="width:255px; height:310px; -webkit-appearance: none; -webkit-border-radius:0px;">
        <img src="apple.png"  />
    </button>
</form>

When the button is clicked, it is supposed to open up the URL in the "action" part in the form tag. However, all I get is the JS pop-up, but no URL is opened (looking at the console, a GET function is triggered, then instantly canceled). IS there something I need to add/remove in order for this to work?

Upvotes: 0

Views: 145

Answers (1)

Robbert
Robbert

Reputation: 6582

Submit the form with the onclick event

onclick="alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.');this.form.submit();"

You don't need to put the work JavaScript in your event either.

BTW, you don't really need to have this.form.submit() at all. I took your original and removed JavaScript from the onlick and changed the action and your code works fine. I'm not sure what itms-services:// is but it's not a valid HTTP protocol like http:// or https://.

Here's a jsfiddle illustrating this.

Upvotes: 1

Related Questions