Javascript Form not posting anything into the body - javascript

The Javascript form submits all the information except for the body part.
<form action="javascript:;" method="post" enctype="text/plain" onSubmit="this.action='mailto:'
+document.getElementById('friend1').value+','
+document.getElementById('friend2').value+','
+document.getElementById('friend3').value+
'?cc=test#test.com&subject=Tester and space&body=testit';">
<input type="Email" id="friend1" value="" required placeholder="1st friend's email"/><br>
<input type="Email" id="friend2" value="" required placeholder="2nd friend's email"/><br>
<input type="Email" id="friend3" value="" required placeholder="3rd friend's email"/><br>
<input type="submit" value="Send">
</form>
The part that is suppose to change the contents of the body located in the "onSubmit" action in the form:
&body=testit
Any help would be appreciated. Thanks in advance. :)

Replace your spaces in the subject with %20. I remember having an issue with this years ago. It has to do with the encoding.
&subject=Tester%20and%20space

Related

Can we submit an html post form in react-native?

I have a question if we can submit an html post form with Linking in react-native. If yes how we can submit it?
I want to submit it to default browser (not with webview) and here is html form:
<form method="POST" target="..." id="..." :action="videoConferenceUrl">
<input type="hidden" name="target" value="..."/>
<input type="hidden" name="requestOrigin" value="..."/>
<input type="hidden" name="username" :value="..."/>
<input type="hidden" name="password" :value="..."/>
<input type="hidden" name="eventID" :value="..."/>
</form>
Please write every way how we can submit that form in the default browser.
Thanks in advance.

Javascript Submit from from pageA to pageB

I am trying to write some code where I have the pageA.html and pageB.html
On pageB.html I have a form:
<form>
First name:<br>
<input type="text" name="firstname" value="">
<br>
Last name:<br>
<input type="text" name="lastname" value="">
<br><br>
<input type="submit" value="Submit">
</form>
Both pages are on my localhost.
I need to add some code on pageA.html that with hit the submit button on pageB.html
Is this possible? If yes, How can I do this?
No, It is not possible by using only html. You have to use any server-side scripting language like PHP or C# etc.

Simulate a submit button click via JavaScript

Is it possible to Submit a form with JAVASCRIPT? if yes please help me...
I have a form with input fileds in it. So I want javascript to count if all fields are field in and then press on the submit button.
The submit button "Save" will be hidden from visitors eyes.
<form id="my form" action="">
<input type="text" name="fname" id="fname" value=""/>
<input type="text" name="sname" id="sname" value=""/>
<input type="text" name="email" id="email" value=""/>
<button type="submit" name="submitAccount" id="submitAccount">save</button>
</form>
here is a opened FIDDLE
Thanks to all for any help!
you can submit form via JavaScript even without submit button, form element has method .submit() which submits whole form.
var myForm = document.getElementById('myform');
myForm.submit();
Before submiting form you can get values from every field in form and make you own validation.
P.S. don't use values for id attribute with whitespace, you should rename it to 'myform' or 'myForm'.
There is a required attribute
<form id="myForm" action="">
<input type="text" name="fname" id="fname" value="" required/>
<input type="text" name="sname" id="sname" value="" required/>
<input type="text" name="email" id="email" value="" required/>
<button type="button" name="submitAccount" id="submitAccount" onclick="checkForm();">save</button>
</form>
Form gets submitted only if the required fields are filled

Javascript animates both form fields, only want one

I have a search and a subscribe field. I want them both to look and feel the same, so I copied the working code from the search field to the subscribe field. The fields should expand when you click on them, and the value disappears so the user can enter their own. The only thing is that now when you click on one of the fields, the animation happens to both fields. I think the problem may be with my understanding of "this" in javascript, but perhaps not. Any help would be greatly appreciated.
<br />
<form target="_blank" id="subscribe" method="post" action="https://www.myaction.com">
<p>
<input type="hidden" name="username" value="myusername">
<input type="text" name="email" value="Email Address" id="subscribe" onfocus="javascript:if(this.value=='Email Address')this.value='';" onblur="this.value=!this.value?'Email Address':this.value;" maxlength="100">
</p>
<br />
<input type="submit" value="Subscribe" />
</form>
<input type="text" name="email" value="Email Address" id="subscribe" onfocus="this.value = this.value ==='Email Address' ? '' : this.value;" onblur="this.value = this.value || 'Email Address';" maxlength="100">
The problem ended up being in my HTML. Stupid mistake. Thanks for your help.

Hiding and showing Divs with form validation

Upon submit I am trying to have "quiz" hide and have "thanks" be shown. All was working correct until I added a JavaScript form validation code, and now it just reloads the first div "welcome" I thought adding "#thanks" to the action upon submit would solve the issue, but it did not. Then trying to add an "if true" statement to my form validation ended up breaking the form validation. I am using jquery.validate to validate my form as suggested. With the current code it skips the validation and just shows "thanks" If anyone has any suggestions it would be greatly appreciated.
<div id="quiz">
<form class="cmxform" id="commentForm" method="get" action="" onSubmit="showHide(); return false;">
<label for="cname">Name</label>
<input id="cname" name="name" size="20" class="required" minlength="2" />
</p>
<p>
<label for="ccompany">Company Title</label>
<input id="ccompany" name="company" size="20" class="required company" minlength="2" />
</p>
<p>
<label for="cnumber">Phone Number</label>
<input id="cnumber" name="number" size="20" class="required number" />
</p>
<p>
<label for="cemail">Email</label>
<input id="cemail" name="email" size="20" class="required email" />
<p></p>
<input class="submit" type="submit" value="Submit" align="center"/>
</form>
</div>
<div id="thanks"><h2>Thank you.</h2>
You will receive an email momentarily
</div>
<script>
$("#begin").click(function(){
$("#quiz").show();
$("#welcome").hide();
});
function showHide(){
$("#thanks").show();
$("#quiz").hide();
};
</script>
All I can say is that you are doing it wrong.... While the form validation that you are doing can work there are a lot of good form validation jquery plugins that would both simplify your life and add a much richer user experience. jquery.validate is probably the most widely used library and would be well worth using.

Categories