Submit request via button javascript - SwiftCreate GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
How to make a list of partial sums using forEach
Showing mass murder in a kid's book
Is there a distance limit for minecart tracks?
How much do grades matter for a future academia position?
What happens if I try to grapple mirror image?
How can ruler support inventing of useful things?
Would this string work as string?
Why is the sun approximated as a black body at ~ 5800 K?
Why does a 97 / 92 key piano exist by Bösendorfer?
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Telemetry for feature health
Echo with obfuscation
Quoting Keynes in a lecture
Language involving irrational number is not a CFL
If A is dense in Q, then it must be dense in R.
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Do I have to take mana from my deck or hand when tapping a dual land?
The Digit Triangles
Giving feedback to someone without sounding prejudiced
How to test the sharpness of a knife?
Personal or impersonal in a technical resume
Why do Radio Buttons not fill the entire outer circle?
Isometric embedding of a genus g surface
What should be the ideal length of sentences in a blog post for ease of reading?
Submit request via button javascript - Swift
Create GUID / UUID in JavaScript?How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
Probably the title is not 100% correct. I'm writing an app in Swift and after that I filled two field of a form I want to submit them. So the button is created in this way:
<button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button>
For fill the 2 field of the form I used:
webView.evaluateJavaScript("document.getElementsByName('email')[0].value='(firstTf.text!)'", completionHandler: nil)
But I'm totally lost for what about submit the request... Any ideas? Thank you!
EDIT:
This is the form HTML code:
<form action="/login" class="measure center" data-test="login-form" method="POST"><input id="__anti-forgery-token" name="__anti-forgery-token" type="hidden" value="I/ulxtAepoMOjZvudrMhXDSqp89wIKM6hPkw7G6xHyYOqfcQIi3S/EVey1L7/CvHZI3SCbJ3Qa5rcl4j"><div class="mb3"><label class="db f6 mb2 b">Email</label><input class="mb1 pv2 lh-copy ph3 input-reset sans-serif black-80 ba bg-transparent w-100 b--black-20" name="email" type="email"><div class="f6 black-50 dn">Don't worry, we hate spam as much as you do</div></div><div class="mb3"><label class="db f6 mb2 b">Password</label><input class="pv2 lh-copy ph3 input-reset sans-serif ba bg-transparent w-100 b--black-20" name="password" type="password"></div><div class="mv3 lh-title"></div><div><button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button></div><div class="f6 black-50 tc lh-copy"><div><a class="link blue hover-dark-blue ml1 dib" data-test="forgot-password" href="/reset-password">Forgot your password?</a></div></div></form>
javascript swift form-submit
add a comment |
Probably the title is not 100% correct. I'm writing an app in Swift and after that I filled two field of a form I want to submit them. So the button is created in this way:
<button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button>
For fill the 2 field of the form I used:
webView.evaluateJavaScript("document.getElementsByName('email')[0].value='(firstTf.text!)'", completionHandler: nil)
But I'm totally lost for what about submit the request... Any ideas? Thank you!
EDIT:
This is the form HTML code:
<form action="/login" class="measure center" data-test="login-form" method="POST"><input id="__anti-forgery-token" name="__anti-forgery-token" type="hidden" value="I/ulxtAepoMOjZvudrMhXDSqp89wIKM6hPkw7G6xHyYOqfcQIi3S/EVey1L7/CvHZI3SCbJ3Qa5rcl4j"><div class="mb3"><label class="db f6 mb2 b">Email</label><input class="mb1 pv2 lh-copy ph3 input-reset sans-serif black-80 ba bg-transparent w-100 b--black-20" name="email" type="email"><div class="f6 black-50 dn">Don't worry, we hate spam as much as you do</div></div><div class="mb3"><label class="db f6 mb2 b">Password</label><input class="pv2 lh-copy ph3 input-reset sans-serif ba bg-transparent w-100 b--black-20" name="password" type="password"></div><div class="mv3 lh-title"></div><div><button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button></div><div class="f6 black-50 tc lh-copy"><div><a class="link blue hover-dark-blue ml1 dib" data-test="forgot-password" href="/reset-password">Forgot your password?</a></div></div></form>
javascript swift form-submit
add a comment |
Probably the title is not 100% correct. I'm writing an app in Swift and after that I filled two field of a form I want to submit them. So the button is created in this way:
<button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button>
For fill the 2 field of the form I used:
webView.evaluateJavaScript("document.getElementsByName('email')[0].value='(firstTf.text!)'", completionHandler: nil)
But I'm totally lost for what about submit the request... Any ideas? Thank you!
EDIT:
This is the form HTML code:
<form action="/login" class="measure center" data-test="login-form" method="POST"><input id="__anti-forgery-token" name="__anti-forgery-token" type="hidden" value="I/ulxtAepoMOjZvudrMhXDSqp89wIKM6hPkw7G6xHyYOqfcQIi3S/EVey1L7/CvHZI3SCbJ3Qa5rcl4j"><div class="mb3"><label class="db f6 mb2 b">Email</label><input class="mb1 pv2 lh-copy ph3 input-reset sans-serif black-80 ba bg-transparent w-100 b--black-20" name="email" type="email"><div class="f6 black-50 dn">Don't worry, we hate spam as much as you do</div></div><div class="mb3"><label class="db f6 mb2 b">Password</label><input class="pv2 lh-copy ph3 input-reset sans-serif ba bg-transparent w-100 b--black-20" name="password" type="password"></div><div class="mv3 lh-title"></div><div><button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button></div><div class="f6 black-50 tc lh-copy"><div><a class="link blue hover-dark-blue ml1 dib" data-test="forgot-password" href="/reset-password">Forgot your password?</a></div></div></form>
javascript swift form-submit
Probably the title is not 100% correct. I'm writing an app in Swift and after that I filled two field of a form I want to submit them. So the button is created in this way:
<button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button>
For fill the 2 field of the form I used:
webView.evaluateJavaScript("document.getElementsByName('email')[0].value='(firstTf.text!)'", completionHandler: nil)
But I'm totally lost for what about submit the request... Any ideas? Thank you!
EDIT:
This is the form HTML code:
<form action="/login" class="measure center" data-test="login-form" method="POST"><input id="__anti-forgery-token" name="__anti-forgery-token" type="hidden" value="I/ulxtAepoMOjZvudrMhXDSqp89wIKM6hPkw7G6xHyYOqfcQIi3S/EVey1L7/CvHZI3SCbJ3Qa5rcl4j"><div class="mb3"><label class="db f6 mb2 b">Email</label><input class="mb1 pv2 lh-copy ph3 input-reset sans-serif black-80 ba bg-transparent w-100 b--black-20" name="email" type="email"><div class="f6 black-50 dn">Don't worry, we hate spam as much as you do</div></div><div class="mb3"><label class="db f6 mb2 b">Password</label><input class="pv2 lh-copy ph3 input-reset sans-serif ba bg-transparent w-100 b--black-20" name="password" type="password"></div><div class="mv3 lh-title"></div><div><button class="mb3 w-100 input-reset sans-serif pointer bg-blue hover-bg-white hover-blue bg-animate ba ph3 pv2 lh-copy white b--blue b br0" data-test="login-btn">Log in</button></div><div class="f6 black-50 tc lh-copy"><div><a class="link blue hover-dark-blue ml1 dib" data-test="forgot-password" href="/reset-password">Forgot your password?</a></div></div></form>
javascript swift form-submit
javascript swift form-submit
edited Mar 8 at 7:29
Pietro Messineo
asked Mar 7 at 21:51
Pietro MessineoPietro Messineo
13112
13112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Fetch the element and then call .submit() on it.
webView.evaluateJavaScript("document.getElementById('FORM').submit()", completionHandler: nil)
something like this might do the job for you.
Since the form don't have an id, I assume that you don't have control over the website that you are showing, so adding an id is not an option. Because i don't have the whole page I would like to have an id to get from. You can navigate the DOM and get a child of the form that has an id and then ask for the parent.
document.getElementById('__anti-forgery-token').parentNode.submit()
This should invoke a submit of the form.
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
add a comment |
I found the answer.Instead of use "submit()" on TagName, I used "click()" as follow:
webView.evaluateJavaScript("document.getElementsByTagName('button')[0].click()", completionHandler: nil)
That is not true, you can usesubmit()ongetElementsByTagNameits just a DOM selector, it does not determine the methods you can use on it.
– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
Read my updated answer,getElementByIdis just a method to get a node from the DOM.getElementsByTagNameis also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.
– Nils Kähler
Mar 8 at 7:56
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053367%2fsubmit-request-via-button-javascript-swift%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Fetch the element and then call .submit() on it.
webView.evaluateJavaScript("document.getElementById('FORM').submit()", completionHandler: nil)
something like this might do the job for you.
Since the form don't have an id, I assume that you don't have control over the website that you are showing, so adding an id is not an option. Because i don't have the whole page I would like to have an id to get from. You can navigate the DOM and get a child of the form that has an id and then ask for the parent.
document.getElementById('__anti-forgery-token').parentNode.submit()
This should invoke a submit of the form.
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
add a comment |
Fetch the element and then call .submit() on it.
webView.evaluateJavaScript("document.getElementById('FORM').submit()", completionHandler: nil)
something like this might do the job for you.
Since the form don't have an id, I assume that you don't have control over the website that you are showing, so adding an id is not an option. Because i don't have the whole page I would like to have an id to get from. You can navigate the DOM and get a child of the form that has an id and then ask for the parent.
document.getElementById('__anti-forgery-token').parentNode.submit()
This should invoke a submit of the form.
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
add a comment |
Fetch the element and then call .submit() on it.
webView.evaluateJavaScript("document.getElementById('FORM').submit()", completionHandler: nil)
something like this might do the job for you.
Since the form don't have an id, I assume that you don't have control over the website that you are showing, so adding an id is not an option. Because i don't have the whole page I would like to have an id to get from. You can navigate the DOM and get a child of the form that has an id and then ask for the parent.
document.getElementById('__anti-forgery-token').parentNode.submit()
This should invoke a submit of the form.
Fetch the element and then call .submit() on it.
webView.evaluateJavaScript("document.getElementById('FORM').submit()", completionHandler: nil)
something like this might do the job for you.
Since the form don't have an id, I assume that you don't have control over the website that you are showing, so adding an id is not an option. Because i don't have the whole page I would like to have an id to get from. You can navigate the DOM and get a child of the form that has an id and then ask for the parent.
document.getElementById('__anti-forgery-token').parentNode.submit()
This should invoke a submit of the form.
edited Mar 8 at 7:43
answered Mar 7 at 22:00
Nils KählerNils Kähler
604516
604516
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
add a comment |
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
I will try and I’ll let you know. Thanks for the answer !
– Pietro Messineo
Mar 7 at 22:02
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
@PietroMessineo did you make it work?
– Nils Kähler
Mar 7 at 22:53
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
Sorry, cause of the Time Zone difference I didn't have the time to test... Unfortunately it's not working because there is no ID "FORM" in any HTML lines
– Pietro Messineo
Mar 8 at 7:28
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
I added the code of the form
– Pietro Messineo
Mar 8 at 7:30
This is also working
– Pietro Messineo
Mar 8 at 7:54
This is also working
– Pietro Messineo
Mar 8 at 7:54
add a comment |
I found the answer.Instead of use "submit()" on TagName, I used "click()" as follow:
webView.evaluateJavaScript("document.getElementsByTagName('button')[0].click()", completionHandler: nil)
That is not true, you can usesubmit()ongetElementsByTagNameits just a DOM selector, it does not determine the methods you can use on it.
– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
Read my updated answer,getElementByIdis just a method to get a node from the DOM.getElementsByTagNameis also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.
– Nils Kähler
Mar 8 at 7:56
|
show 3 more comments
I found the answer.Instead of use "submit()" on TagName, I used "click()" as follow:
webView.evaluateJavaScript("document.getElementsByTagName('button')[0].click()", completionHandler: nil)
That is not true, you can usesubmit()ongetElementsByTagNameits just a DOM selector, it does not determine the methods you can use on it.
– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
Read my updated answer,getElementByIdis just a method to get a node from the DOM.getElementsByTagNameis also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.
– Nils Kähler
Mar 8 at 7:56
|
show 3 more comments
I found the answer.Instead of use "submit()" on TagName, I used "click()" as follow:
webView.evaluateJavaScript("document.getElementsByTagName('button')[0].click()", completionHandler: nil)
I found the answer.Instead of use "submit()" on TagName, I used "click()" as follow:
webView.evaluateJavaScript("document.getElementsByTagName('button')[0].click()", completionHandler: nil)
edited Mar 8 at 7:51
answered Mar 8 at 7:39
Pietro MessineoPietro Messineo
13112
13112
That is not true, you can usesubmit()ongetElementsByTagNameits just a DOM selector, it does not determine the methods you can use on it.
– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
Read my updated answer,getElementByIdis just a method to get a node from the DOM.getElementsByTagNameis also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.
– Nils Kähler
Mar 8 at 7:56
|
show 3 more comments
That is not true, you can usesubmit()ongetElementsByTagNameits just a DOM selector, it does not determine the methods you can use on it.
– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
Read my updated answer,getElementByIdis just a method to get a node from the DOM.getElementsByTagNameis also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.
– Nils Kähler
Mar 8 at 7:56
That is not true, you can use
submit() on getElementsByTagName its just a DOM selector, it does not determine the methods you can use on it.– Nils Kähler
Mar 8 at 7:49
That is not true, you can use
submit() on getElementsByTagName its just a DOM selector, it does not determine the methods you can use on it.– Nils Kähler
Mar 8 at 7:49
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
But with submit() is not working and with click() yes ...
– Pietro Messineo
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Perhaps your code is wrong. It could be a subject for a new question. But what you are writing is not true.
– Nils Kähler
Mar 8 at 7:50
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
Not at all... As you can see is the same as the previous, with the only difference that is not submit() but click()...
– Pietro Messineo
Mar 8 at 7:51
1
1
Read my updated answer,
getElementById is just a method to get a node from the DOM. getElementsByTagName is also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.– Nils Kähler
Mar 8 at 7:56
Read my updated answer,
getElementById is just a method to get a node from the DOM. getElementsByTagName is also just a selector for the DOM, it does not influence the methods a node has. I use getElementsById because the ID is unique and i don't know your whole DOM on the page you are looking, and I'm sure the parent is form.– Nils Kähler
Mar 8 at 7:56
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053367%2fsubmit-request-via-button-javascript-swift%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown