On clicking submit button how to hide the below div class. I have tried >with div id but div class is not working as exactly as div id. As I have
written the code but It was closing entire window. Below is the code without adding jquery.
<div class="w3-container w3-light-grey w3-padding-32 w3-padding-large" id="contact">
<div class="w3-content" style="max-width:600px">
<h4 class="w3-center"><b>Please fill the form to continue</b></h4>
<script type="text/javascript">var submitted=false;</script>
<!--Update the URL for thank you page on form submit -->
<iframe name="hidden_iframe" id="hidden_iframe" style="display:none;"
onload="if(submitted) {window.location='';}"></iframe>
<!-- Update the Google forms URL in action-->
<form class= 'form1' action="https://docs.google.com/forms/u/0/d/a/1FAIlQLDFDHBaSVqkaf1BLTQ1MeRa1NH8OGw4Tpj_SZUvRj-QUTYu9Qw/formResponse" method="post" target="hidden_iframe" onsubmit="return validateForm(); ">
<div class="w3-section">
<label>Name</label>
<input class="w3-input w3-border" type="text" placeholder="Name" id="name" required name="entry.482263238">
</div>
<div class="w3-section">
<label>Email</label>
<input class="w3-input w3-border" type="text" placeholder="Email" id="email" required name="entry.227786006">
</div>
<div class="w3-section">
<label>Phone</label>
<input class="w3-input w3-border" type="text" placeholder="Phone" id="phone" required name="entry.30499006">
</div>
<div class="w3-section">
<button class="w3-button w3-block w3-black w3-margin-bottom" type="submit">submit</button>
</div>
</form>
</div>
</div>
In case you want to hide the entire form, you can add form.style.display = "none" to your validateForm() function:
const form = document.querySelector(".w3-container");
function validateForm() {
form.style.display = "none";
}
The same methodology applies if you want to hide some other div, just select it and apply element.style.display = "none";.
JSfiddle: Link
Related
I have a php form with angularjs code. The initial screen looks like
Before submit
Once the user submit the form I would like to blank out all fields, However the following code doesnot seem to do so for the field, but does for the button.
after submit
Before
After
the form and code is as follow, i tried blanking the email field. The button is changed so I know it going thru the angularjs code.
<!-- Contact Section Angularjs -->
<div id="myapp" ng-controller="contacts_empcontroller">
<div id="contact" class="w3-container w3-padding-16" >
<h3 class="w3-border-bottom w3-border-light-grey w3-padding-16">Contact</h3>
<form id="contact_02" >
<p><h4> If you would like to book an event or conference please contact us.</h4></p>
<p ng-bind="msg1"></p>
<input id="name1" class="w3-input w3-section" type="text" placeholder="Name" required name="Name" value=" " ng-model="name1">
<input id="email1" class="w3-input w3-section" type="text" placeholder="Email" required name="Email" value="" ng-model="email1">
<input id="subject1" class="w3-input w3-section" type="text" placeholder="Subject" required name="Subject" value="" ng-model="subject1">
<input id="comment1" class="w3-input w3-section" type="text" placeholder="Comment" required name="Comment" value="" ng-model="comment1">
<input id="token1" class="w3-input w3-section" type="hidden" name="token1" value="<?php echo $token;?>" >
<button class="w3-button w3-black w3-section" ng-click="postData()" id="buttoncontact" >Send Message</button></p>
</form>
</div>
</div>
Angularjs code
if (data.success == "ip_over_2")
{
document.getElementById("buttoncontact").innerHTML = "Duplicate - Thanks";
document.getElementById("email1").innerHTML = "-";
}
Thanks for any help
Second form
<div class=" col-sm-4 ">
<div id="myapp" ng-controller="subscribe_controller">
<h4 style="color:black;" >Subscribe To Newsletter</h4>
<form id="subscribe_01">
<h4>
<p ng-bind="msg2"></p>
<input id="email2" style="color:gray;" type="text" name="EMAIL" placeholder="Your Email Adddress" value="" ng-model="email2" required ></h4>
<input id="token2" class="w3-input w3-section" type="hidden" name="token2" value="<?php echo $token;?>" >
Enter Code: <font size="3" color="blue"><?php echo $captcha_token;?> </font>  
<input id="captcha" type="text" placeholder="Code" name="captcha" value="" ng-model="captcha" size="10" required>
<p><p>
<button class="w3-button w3-black" ng-click="postData_subscribe()" id="buttoncontact_subscribe">Send To Subscribe</button></p>
</form>
</div>
Instead of document.getElementById("...").innerHTML; just do:
$scope.name1 = '';
$scope.email1 = '';
$scope.subject1 = '';
$scope.comment1 = '';
This will update your model (ng-model="email1") with the specified value, in this case a blank value (as you specified was the goal).
I have a code that submits form by clicking <input type="submit">, and I want to change my form to submit when label, which is outside of the form, is clicked.
What should I do?
Here's my code:
<div class="join">
<p>Join</p>
<span>Join to access all features of the site!</span>
</div>
<form action="join/joinf" method="POST" class="joinform">
<div class="left">
<p>ID<span class="required"> *required</span></p>
<p>PW<span class="required"> *required</span></p>
</div>
<div class="right">
<p><input type="text" name="id" id="id" required>
<p><input type="password" name="pw" required></p>
</div>
<input type="submit" id="formsub" value="join">
</form>
<label for="formsub"><button>join-label</button></label>
Try using Jquery click element, set id for label .
$('#LabelId').click(function(e) {
e.preventDefault();
$("#formsub").submit();
});
I have the following HTML code:
<section id="two" class="wrapper alt style2">
<section dir="rtl">
<center>
<h1> מילוי פרטים אישיים לתעודת אחריות</h1>
</center>
<br>
<!-->
<form method="post" action="#">
<!-->
<form id="frmcontainer6" method="post" enctype="application/x-www-form-urlencoded" action="https://web.mxradon.com/t/FormTracker.aspx" onsubmit="return lpContentGrabber('frmcontainer6');">
<!-->
<form action="mailto:graphics#emka.co.il" method="post">
<!-->
<div class="row uniform">
<div class="6u 12u$(xsmall)">
<input type="text" id="EfullName" name="EfullName" maxlength="100" value="" placeholder="שם מלא" autocomplete="off" />
</div>
<div class="6u$ 12u$(xsmall)">
<input type="email" name="email" id="email" value="" placeholder="Email" required />
</div>
<div class="6u 12u$(xsmall)">
<input type="text" name="PhoneNu" id="PhoneNu" value="" placeholder="מספר טלפון" required />
</div>
<div class="6u$ 12u$(xsmall)">
<input type="text" name="CAdress" id="CAdress" value="" placeholder="כתובת" required />
</div>
<br>
<div class="6u 12u$(xsmall)">
<input type="text" id="Pmodel" name="Pmodel" maxlength="100" value="" autocomplete="off">
</div>
<div class="6u$ 12u$(xsmall)">
<input type="text" name="SerialNu" value="SN12-8486-EF19-8541" id="SerialNu" readonly/>
</div>
<div class="12u$">
<textarea name="message" id="message" placeholder="הערות נוספות" rows="6"></textarea>
</div>
<div class="image center">
<input type="checkbox" id="demo-copy" name="demo-copy">
<label for="demo-copy">סמן לקבלת מבצעים והנחות למייל</label>
</div>
<div class="12u$">
<ul class="actions">
<center>
<li>
<input type="submit" value="שלח טופס" class="special" />
</li>
<li>
<button type="reset" value="Reset">נקה טופס</button>
</li>
</center>
</ul>
</div>
</div>
</form>
</section>
I'm trying to pre-fill the Pmodel value by URL using somthing like
www.ee.com?Pmodel=123456
but it doesn't work.
What am I doing wrong?
You're just inserting it as a URL parameter. In order to pre-fill the value you need to retrieve it from the URL and insert it as a value for the Pmodel element.
You can do this either on the server side (for example PHP, Java, depends on your server) or on client's side with JavaScript after the page loads.
For example (JavaScript) insert this script on the end of your page:
<script type="text/javascript">
//get all URL parameters
var parameters = window.location.search.substring(1).split("&");
var splitParam, value;
//cycle through them and find the correct one
for(var i=0; i<parameters.length; i++){
splitParam = parameters[i].split("=");
if(splitParam[0]=="Pmodel"){
//get its value
value = splitParam[1];
break;
}
}
if(value){
//set the input value
document.getElementById("Pmodel").value = value;
}
</script>
Example for filling: jsFiddle
I have a new login page which is not submitting. :(
If I click the button and the required fields are not entered, it fires me back the errors, but as soon as they're filled and I try to submit it does nothing.
The page is live at https://www.safewise.co.nz/trainwise/login
The code
<form action="login.php" method="post" name="logForm" id="logForm" class="styled_form">
<?php if(isset($redirectURL) && !empty($redirectURL)) { ?><input type="hidden" id="redirect" name="redirect" value="<?php echo $redirectURL; ?>" /><?php } ?>
<div>
<p id="login-title">Login</p>
<input name="userEmail" type="email" class="validate[required]" id="userEmail" placeholder="Email"<?php if(isset($enteredEmail) && !empty($enteredEmail)){echo ' value="'.$enteredEmail.'"';} ?> required /><span class="form_hint">Email Address</span>
<input name="userPwd" type="password" class="validate[required]" placeholder="Password" id="userPwd" required /><span class="form_hint">Password</span>
<div class="login-checkbox"><input type="checkbox" name="remember" id="remember" style="vertical-align:middle;" /> <label for="remember">Remember Me</label></div>
<p><input name="doLogin" type="submit" id="doLogin" value="Continue" class="form-button" /></p>
<div id="forgot"><p>Register</p><p>Forgotten Password?</p>
</div>
</form>
<div id="forgotPass" class="reveal-modal">
<div class="modal-header"><h3>Forgot Password</h3></div>
<div class="modal-body" style="text-align:center;">
<form action="login.php" method="post" name="forgotForm" id="forgotForm" >
<p style="margin-bottom:4px;"><em style="font-size:small;color:#3A3A3A">Enter your email address below to receive your new password.</em></p>
<p><input name="rstEmail" type="text" class="validate[required]" id="rstEmail" placeholder="john#example.com" size="25" /> <input name="doReset" type="submit" id="doReset" value="Reset" class="form-button" /></p>
</form>
</div>
<a class="close-reveal-modal">×</a>
</div>
The weird thing is as soon as I remove this code it works.
<div id="forgotPass" class="reveal-modal">
<div class="modal-header"><h3>Forgot Password</h3></div>
<div class="modal-body" style="text-align:center;">
<form action="login.php" method="post" name="forgotForm" id="forgotForm" >
<p style="margin-bottom:4px;"><em style="font-size:small;color:#3A3A3A">Enter your email address below to receive your new password.</em></p>
<p><input name="rstEmail" type="text" class="validate[required]" id="rstEmail" placeholder="john#example.com" size="25" /> <input name="doReset" type="submit" id="doReset" value="Reset" class="form-button" /></p>
</form>
</div>
<a class="close-reveal-modal">×</a>
</div>
Any suggestions?
Where is that div located in the page? It is incorrect to have a form inside a form. And so your code may work when you remove the div above because you've taken out the second form.
Consider having them as two separate entities instead of nested.
Are these forms nested? You cannot have nested forms. You can have multiple forms in a page, just as long they're not nested.
Here's some ref on it http://www.w3.org/MarkUp/html3/forms.html
I was missing a closing div
<div id="forgot">
<p>Register</p>
<p>Forgotten Password?</p>
Needs a closing div at end
<div id="forgot">
<p>Register</p>
<p>Forgotten Password?</p>
</div>
I'm trying to remove the message box and I want to move the e-mail box to the right of the name, so that it all fits into the top bar.
I have tried removing the message box through the html code, but when I do, I get errors and it doesn't function properly.
I assume I have to remove something in the PHP because it's obviously not able to find the missing html code, but as I don't understand PHP I don't know what to remove.
this is the html code for the subscribe button
<div class="subscribe">
<div class="containerContact">
<div id="contactFormContainer">
<div id="contactForm">
<div class="loader"></div>
<div class="bar"></div>
<form action="mail.php" class="contactForm" name="cform" method="post">
<div class="input_boxes">
<p><label for="name">Name</label><span class="name-missing">Please enter your name</span><br />
<input id="name" type="text" value="" name="name" />
</p>
<p>
<label for="e-mail">E-mail</label><span class="email-missing">Please enter a valid e-mail</span><br />
<input id="e-mail" type="text" value="" name="email" />
</p>
<p><label for="message">Message</label><span class="message-missing">Say something!</span><br />
<textarea id="message" rows="" cols="" name="message"></textarea>
</p>
</div>
<input class="submit" type="submit" name="submit" value="Submit Form" onfocus="this.blur()" />
</form>
</div>
<div class="contact"></div>
</div>
</div>
<!-- this is the overlay which hides the rest of the website when the Subscribe button is pressed. -->
<div id="backgroundPopup"></div>
</div>
I can't post more than one link, so here is a text dump to the PHP and CSS for the subscribe button
any help would be much appreciated!!