<form action="/users/student/update" method="POST">
<div class="personal">
<h3 style="padding: 0 22px;">PERSONAL DETAILS</h3>
<hr style="width: 25%; margin-left: 0; border: 1px solid black;">
<label for="name" class="d">Name :</label>
<input id="name" type="text" value= profileInformation.Name name="Name">
<hr>
<label for="email" class="e">Email :</label>
<input id="email" type="email" value="profileInformation.email" name="email">
<hr>
</div>
<hr style="border: 2px solid black;">
<input class="btn" type="submit" value="Submit">
</form>
In this code, profileInformation is a data object, and name and email are variables in it. I want to use them as default values. Right now, it is being printed as ProfileInformation.name and not the value. Please help.
You cannot do that in HTML. You need javascript for that.
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("name").value = profileInformation.name;
document.getElementById("email").value = profileInformation.email;
});
const profileInformation = {
name: "some name",
email: "test#gmail.com"
};
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("name").value = profileInformation.name;
document.getElementById("email").value = profileInformation.email;
});
<form action="/users/student/update" method="POST">
<div class="personal">
<h3 style="padding: 0 22px;">PERSONAL DETAILS</h3>
<hr style="width: 25%; margin-left: 0; border: 1px solid black;">
<label for="name" class="d">Name :</label>
<input id="name" type="text" name="Name">
<hr>
<label for="email" class="e">Email :</label>
<input id="email" type="email" name="email">
<hr>
</div>
<hr style="border: 2px solid black;">
<input class="btn" type="submit" value="Submit">
</form>
Related
Why is display:flex on #skipperForm producing weird result of all elements on same line?
Curiously, if we change to display:block we get a much better result. But why is flex not working?
body{
max-width:800px;
margin:0 auto;
}
#links a{
text-decoration:none;
}
#links ul{
list-style-type:none;
margin:0 15px;
padding:0;
}
#links li{
display:inline;
}
#skipperForm{
display:flex;
justify-content:center;
margin-top:20px;
}
.radio, .dt, .bc, .label{
width:20vw;
margin:0;
max-width:200px;
}
.label{
display:inline-flex;
justify-content:center;
font-size:20px;
}
.break{
flex-basis:100%;
height:0;
}
#text{
width:60%;
}
.row{
margin-bottom:25px;
}
<form id='skipperForm'>
<label class='label' for='res'>Reservation</label>
<label class='label' for='sail'>Sail</label>
<label class='label' for='xcl'>Cancel</label>
<div class='break'></div>
<input id='res' type='radio' class='radio row' name='sailType' value='RES'>
<input id='sail' type='radio' class='radio row' name='sailType' value='SAIL'>
<input id='xcl' type='radio' class='radio row' name='sailType' value='XCL'>
<div class='break'></div>
<label class='label' for='date'>Date</label>
<label class='label' for='start'>Start Time</label>
<label class='label' for='end'>End Time</label>
<div class='break'></div>
<input id='date' type='text' class='dt row' name='date'>
<input id='start' type='text' class='dt row' name='start'>
<input id='end' type='text' class='dt row' name='end'>
<div class='break'></div>
<label class='label' for='boat'>Boat</label>
<label class='label' for='spots'>Crew Spots</label>
<label class='label' for='customCrew'>Custom Crew</label>
<div class='break'></div>
<input id='boat' type='text' class='bc row' name='boat'>
<input id='spots' type='text' class='bc row' name='spots'>
<input id='customCrew' type='text' class='bc row' name='customCrew'>
<div class='break'></div>
<textarea id='text' class='row' placeholder='message crew'></textarea>
<div class='break'></div>
<input type='submit' class='row' name='submit' value='update'>
</form>
If you want them to be displayed in row without over cross page width you can add only one line of code to your skipperForm div like this: flex-wrap:wrap;
body{
max-width:800px;
margin:0 auto;
}
#links a{
text-decoration:none;
}
#links ul{
list-style-type:none;
margin:0 15px;
padding:0;
}
#links li{
display:inline;
}
#skipperForm{
display:flex;
flex-wrap:wrap;
justify-content:center;
margin-top:20px;
}
.radio, .dt, .bc, .label{
width:20vw;
margin:0;
max-width:200px;
}
.label{
display:inline-flex;
justify-content:center;
font-size:20px;
}
.break{
flex-basis:100%;
height:0;
}
#text{
width:60%;
}
.row{
margin-bottom:25px;
}
<form id='skipperForm'>
<label class='label' for='res'>Reservation</label>
<label class='label' for='sail'>Sail</label>
<label class='label' for='xcl'>Cancel</label>
<div class='break'></div>
<input id='res' type='radio' class='radio row' name='sailType' value='RES'>
<input id='sail' type='radio' class='radio row' name='sailType' value='SAIL'>
<input id='xcl' type='radio' class='radio row' name='sailType' value='XCL'>
<div class='break'></div>
<label class='label' for='date'>Date</label>
<label class='label' for='start'>Start Time</label>
<label class='label' for='end'>End Time</label>
<div class='break'></div>
<input id='date' type='text' class='dt row' name='date'>
<input id='start' type='text' class='dt row' name='start'>
<input id='end' type='text' class='dt row' name='end'>
<div class='break'></div>
<label class='label' for='boat'>Boat</label>
<label class='label' for='spots'>Crew Spots</label>
<label class='label' for='customCrew'>Custom Crew</label>
<div class='break'></div>
<input id='boat' type='text' class='bc row' name='boat'>
<input id='spots' type='text' class='bc row' name='spots'>
<input id='customCrew' type='text' class='bc row' name='customCrew'>
<div class='break'></div>
<textarea id='text' class='row' placeholder='message crew'></textarea>
<div class='break'></div>
<input type='submit' class='row' name='submit' value='update'>
</form>
display: flex; puts all elements on the same row by default. If you one them stacked on top you need also set flex-direction:column;
I have the following form:
.clearfix:after {
content: "";
display: block;
clear: both;
visibility: hidden;
height: 0;
}
.form_wrapper {
background:#fff;
box-sizing:border-box;
padding:15px;
margin:auto 0;
position:relative;
z-index:1;
-webkit-box-shadow:0 23px 4px -21px rgba(0, 0, 0, 0.9);
-moz-box-shadow:0 23px 4px -21px rgba(0, 0, 0, 0.9);
box-shadow:0 23px 4px -21px rgba(0, 0, 0, 0.9);
}
.form_container {
padding:5px;
border:1px dashed #ccc;
}
.form_wrapper h2 {
font-size:1.5em;
line-height:1.5em;
margin:0;
}
.form_wrapper .title_container {
text-align:center;
margin:-15px -15px 15px;
padding:15px 0;
border-bottom:1px dashed #ccc;
}
.form_wrapper h3 {
font-size:1.1em;
font-weight:normal;
line-height:1.5em;
margin:0;
}
.form_wrapper .row {
margin:10px -15px;
margin-top: 2%;
}
.form_wrapper .row > div {
padding:0 15px;
box-sizing:border-box;
}
.form_wrapper .col_half {
width:50%;
float:left;
}
.form_wrapper .col_half1 {
width:33%;
float:left;
}
.form_wrapper .col_half2 {
width:70%;
float:left;
}
.form_wrapper .col_half9 {
width:30%;
float:left;
}
.form_wrapper .col_half3 {
width:25%;
float:left;
}
.form_wrapper .col_half10 {
width:22%;
float:left;
}
.form_wrapper .col_half6 {
width:16.5%;
float:left;
}
.form_wrapper .col_half8 {
width:17.5%;
float:left;
}
.form_wrapper .col_half7 {
width:15%;
float:left;
}
.form_wrapper .col_half4 {
width:40%;
float:left;
}
.form_wrapper .col_half5 {
width:100%;
float:left;
}
.form_wrapper .col_half11 {
width:42%;
float:left;
}
.form_wrapper label {
display:block;
margin:0 0 5px;
}
.form_wrapper .input_field, .form_wrapper .textarea_field {
position:relative;
}
.form_wrapper .input_field > span, .form_wrapper .textarea_field > span {
position:absolute;
left:0;
top:0;
color:#333;
height:100%;
border-right:1px solid #ccc;
text-align:center;
width:30px;
}
.form_wrapper .textarea_field > span {
border-bottom:1px solid #ccc;
max-height:35px;
}
.form_wrapper .input_field > span > i, .form_wrapper .textarea_field > span > i {
padding-top:12px;
}
.form_wrapper input[type="text"], .form_wrapper input[type="email"], .form_wrapper input[type="tel"], textarea {
width:100%;
padding:10px 10px 10px 35px;
border:1px solid #ccc;
box-sizing:border-box;
outline:none;
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
transition: all 0.30s ease-in-out;
}
.form_wrapper input[type="text"]:focus, .form_wrapper input[type="email"]:focus, .form_wrapper input[type="tel"]:focus, textarea:focus {
-webkit-box-shadow:0 0 2px 1px rgba(255, 169, 0, 0.5);
-moz-box-shadow:0 0 2px 1px rgba(255, 169, 0, 0.5);
box-shadow:0 0 2px 1px rgba(255, 169, 0, 0.5);
border:1px solid #f5ba1a;
}
.credit{
position:relative;
z-index:1;
text-align:center;
padding:15px;
color:#f5ba1a;
}
.credit a{
color:#daa106;
}
#media (max-width: 600px) {
.form_wrapper .col_half {
width:100%;
float:none;
}
.form_wrapper label {
margin:10px 0;
}
}
#media (max-width: 600px) {
.form_wrapper .col_half1 {
width:100%;
float:none;
}
.form_wrapper label {
margin:10px 0;
}
}
#media (max-width: 600px) {
.form_wrapper .col_half2 {
width:100%;
float:none;
}
.form_wrapper label {
margin:10px 0;
}
}
#media (max-width: 600px) {
.form_wrapper .col_half3 {
width:100%;
float:none;
}
.form_wrapper label {
margin:10px 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal-header">
<h4 class="modal-title">IDENTIFICAÇÃO UTENTE</h4>
</div>
<div class="form_wrapper">
<div class="form_container">
<form class="insert_form7">
<div class="row clearfix">
<div class="col_half3">
<label>Código Utente</label>
<div class="input-group-prepend"><span class="input-group-text"> <i class="fa fa-id-card-o" aria-hidden="true"></i></span>
<input type="text" id="codigoinf1" name="codigoinf" value="'.$row["CodigoUtente"].'" class="form-control" readonly="true">
</div>
</div>
<div class="col_half">
<label>Nome Utente</label>
<div class="input-group-prepend"><span class="input-group-text"><i aria-hidden="true" class="fa fa-child"></i></span>
<input type="text" name="nome" value="'.$row["nome"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Data Nascimento</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-birthday-cake" aria-hidden="true"></i></span>
<input type="text" name="DataNasc" value="'.$row["DataNasc"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Valência</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-university" aria-hidden="true"></i></span>
<input type="text" name="Destino" value="'.$row["Destino"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Nacionalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-globe" aria-hidden="true"></i></i></span>
<input type="text" name="Nacionalidade" value="'.$row["Nacionalidade"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Naturalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Naturalidade" value="'.$row["Naturalidade"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Distrito</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Distrito" value="'.$row["Distrito"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Concelho</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Concelho" value="'.$row["Concelho"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half1">
<label>Freguesia</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Freguesia" value="'.$row["Freguesia"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half11">
<label>Morada</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-location-arrow" aria-hidden="true"></i></span>
<input type="text" name="Morada" value="'.$row["Morada"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half6">
<label>Código Postal</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-code" aria-hidden="true"></i></span>
<input type="text" name="CodPostal" value="'.$row["CodPostal"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half">
<label>Encarregado de Educação</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-user-o" aria-hidden="true"></i></span>
<input type="text" name="representante" value="'.$row["representante"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half7">
<label>Parentesco</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-anchor" aria-hidden="true"></i></span>
<input type="text" name="Parentesco" value="'.$row["Discricao"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half8">
<label>Contato</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-mobile" aria-hidden="true"></i></span>
<input type="text" name="telefone" value="'.$row["telefone"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="modal-header">
<h4 class="modal-title">IDENTIFICAÇÃO DA MÃE</h4>
</div>
<div class="row clearfix">
<div class="col_half">
<label>Nome da Mãe</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-female" aria-hidden="true"></i></span>
<input type="text" name="nomemae" value="'.$row["nomemae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Data Nascimento</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-birthday-cake" aria-hidden="true"></i></span>
<input type="text" name="datamae" value="'.$row["datamae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Sexo</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-venus-mars" aria-hidden="true"></i></span>
<input type="text" name="Sexomae" value="'.$row["Sexomae"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Estado Civil</label>
<div class="input-group-prepend"><span class="input-group-text"><i aria-hidden="true" class="far fa-rings-wedding"></i></span>
<input type="text" name="civilmae" value="'.$row["civilmae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Nacionalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-globe" aria-hidden="true"></i></i></span>
<input type="text" name="Nacionalidademae" value="'.$row["Nacionalidademae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Naturalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Naturalidademae" value="'.$row["Naturalidademae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Distrito</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Distritomae" value="'.$row["Distritomae"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Concelho</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Concelhomae" value="'.$row["Concelhomae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half1">
<label>Freguesia</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Freguesiamae" value="'.$row["Freguesiamae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half11">
<label>Morada</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-location-arrow" aria-hidden="true"></i></span>
<input type="text" name="Moradamae" value="'.$row["Moradamae"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half6">
<label>Código Postal</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-code" aria-hidden="true"></i></span>
<input type="text" name="CodPostalmae" value="'.$row["CodPostalmae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half8">
<label>Contato</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-mobile" aria-hidden="true"></i></span>
<input type="text" name="telefonemae" value="'.$row["telefonemae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Habilitações</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-graduation-cap" aria-hidden="true"></i></span>
<input type="text" name="Habilitacoesmae" value="'.$row["Habilitacoesmae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Profissão</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-building" aria-hidden="true"></i></span>
<input type="text" name="Profissaomae" value="'.$row["Profissaomae"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Email</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
<input type="Email" name="Emailmae" value="'.$row["Emailmae"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="modal-header">
<h4 class="modal-title">IDENTIFICAÇÃO DO PAI</h4>
</div>
<div class="row clearfix">
<div class="col_half">
<label>Nome do Pai</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-male" aria-hidden="true"></i></span>
<input type="text" name="nomepai" value="'.$row["nomepai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Data Nascimento</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-birthday-cake" aria-hidden="true"></i></span>
<input type="text" name="datapai" value="'.$row["datapai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Sexo</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-venus-mars" aria-hidden="true"></i></span>
<input type="text" name="Sexopai" value="'.$row["Sexopai"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Estado Civil</label>
<div class="input_field"> <span><i aria-hidden="true" class="far fa-rings-wedding"></i></span>
<input type="text" name="civilpai" value="'.$row["civilpai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Nacionalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-globe" aria-hidden="true"></i></i></span>
<input type="text" name="Nacionalidadepai" value="'.$row["Nacionalidadepai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Naturalidade</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Naturalidadepai" value="'.$row["Naturalidadepai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half3">
<label>Distrito</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Distritopai" value="'.$row["Distritopai"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half3">
<label>Concelho</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Concelhopai" value="'.$row["Concelhopai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half1">
<label>Freguesia</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-map-marker" aria-hidden="true"></i></span>
<input type="text" name="Freguesiapai" value="'.$row["Freguesiapai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half11">
<label>Morada</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-location-arrow" aria-hidden="true"></i></span>
<input type="text" name="Moradapai" value="'.$row["Moradapai"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col_half6">
<label>Código Postal</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-code" aria-hidden="true"></i></span>
<input type="text" name="CodPostalpai" value="'.$row["CodPostalpai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half8">
<label>Contato</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-mobile" aria-hidden="true"></i></span>
<input type="text" name="telefonepai" value="'.$row["telefonepai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Habilitações</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-graduation-cap" aria-hidden="true"></i></span>
<input type="text" name="Habilitacoespai" value="'.$row["Habilitacoespai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Profissão</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-building" aria-hidden="true"></i></span>
<input type="text" name="Profissaopai" value="'.$row["Profissaopai"].'" class="form-control" readonly="true"/>
</div>
</div>
<div class="col_half10">
<label>Email</label>
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
<input type="Email" name="Emailpai" value="'.$row["Emailpai"].'" class="form-control" readonly="true"/>
</div>
</div>
</div>
</form>
</div>
</div>
I intend to email this form with the existing data to the updating user in need. Therefore, the form must be sent in an editable form.
I am in doubt as to how best to do this.
I can export to a doc (word) file and send the doc file by email.
But what I wanted was to send the form exactly as it is and the user to make changes if necessary, is that possible?
The site is not exposed to the outside, it is localhost
I have created a view which is rendered in the kendo window. I have the cancel button on the view. I would like to close the window When I click the cancel button. I have written the code to do it. But nothing seems happening.
Please see the code and screen shot below
Kendo window code
$("#contextMenu").kendoContextMenu({
target: "#grid",
alignToAnchor: false,
select: function (e) {
var selectedItem = e.item; // check this item is add or edit and then open the kendo window
if ($(selectedItem).text() == 'Add' || $(selectedItem).text() == 'Edit') {
var accessWindow = $("#addEdit").kendoWindow({
actions: {}, /*from Vlad's answer*/
draggable: true,
height: "700px",
modal: true,
resizable: false,
title: "Add new User",
width: "800px",
visible: false,
}).data("kendoWindow").center().open();
$("#btnCancel").click(function () {
$(this).closest("[data-role=window]").data("kendoWindow").close();
});
$("#language").kendoDropDownList({
filter: "startswith",
dataTextField: "LanguageDescription",
dataValueField: "LanguageCode",
dataSource: language
//dataSource: {
// type: "odata",
// serverFiltering: true,
// transport: {
// read: {
// url: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",
// }
// }
//}
});
$("#country").kendoDropDownList({
filter: "startswith",
dataTextField: "CountryDescription",
dataValueField: "CountryCode",
dataSource: country
//dataSource: {
// type: "odata",
// serverFiltering: true,
// transport: {
// read: {
// url: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",
// }
// }
//}
});
}
}
});
The view that is rendered in the kendo window
<div id="addEdit" style="width 100%; height 100%; background-color #fff;">
<div class="demo-section k-content">
<ul class="fieldlist">
<li>
<label for="simple-input" >Employee Number</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">ForeName</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">ForeName</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Surname</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Preferred Name</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input" class="form-horizontal">Language</label>
<input id="language" class="form-horizontal" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Country</label>
<input id="country" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Time Zone</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Domain</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Network Id</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Email Address</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<label for="simple-input">Status</label>
<input id="simple-input" type="text" class="k-textbox" style="width: 40%;" />
</li>
<li>
<button id="btnCancel" class="k-button">Cancel</button>
<button class="k-button k-primary">Save</button>
</li>
</ul>
<style>
.fieldlist {
margin: 0 0 -2em;
padding: 0;
}
.fieldlist li {
list-style: none;
padding-bottom: 2em;
}
.fieldlist label {
display: block;
padding-bottom: 1em;
font-weight: bold;
text-transform: uppercase;
font-size: 10px;
color: #444;
}
</style>
</div>
</div>
This has been resolved. I had to add the following jquery to fix it
$("#btnCancel").click(function () {
$(this).closest("[data-role=window]").data("kendoWindow").close();
});
Facing the issue when the code is executed in test script. the same code executes fine in irb
#browser.div(:class=>/DownArrowButton/).when_present.click #works fine, dropdown
popup = #browser.div(:id=>'pgObjectSelector_Popover')
popup.text_fields(:id=>/dijit_form_TextBox_/).select{|s| s.visible?}[0].when_present.set('ethernet')
While setting the key the widget gets closed with an error:
Element is not currently visible and so may not be interacted with
[remote server] file:///C:/Users/suchanna/AppData/Local/Temp/webdriver-profile20150319-30448-a96p5v/extensions/fxdriver#googl
ecode.com/components/command-processor.js:8991:in `fxdriver.preconditions.visible'
Please help me out for the above problem
Html:
<div id="pgObjectSelector_Popover" class="xwtPopover dijitTooltipDialog xwt_BasePickerPopover dijitTooltipABLeft dijitTooltipBelow" wairole="presentation" widgetid="pgObjectSelector_Popover" style="top: 0px; display: none;">
<div class="dijitTooltipContainer" data-dojo-attach-event="onkeypress: _onKey" wairole="dialog" waistate="labelledby-pgObjectSelector_Popover_title" data-dojo-attach-point="_outsideContainer" style="">
<table class="xwtPopoverMenuBar" cellspacing="0" cellpadding="0" data-dojo-attach-point="menuBar" wairole="presentation"></table>
<div class="xwtPopoverPadding" data-dojo-attach-point="_paddingContainer">
<div class="dijitTooltipContents dijitTooltipFocusNode" tabindex="-1" data-dojo-attach-point="_scrollBox" style="overflow-x: hidden;">
<table class="xwtPopoverTable" wairole="presentation">
<tbody>
<tr>
<td wairole="presentation">
<div class="xwtPopoverContainer" wairole="presentation" tabindex="-1" data-dojo-attach-point="containerNode">
<div id="dijit_layout_BorderContainer_0" class="dijitBorderContainerNoGutter dijitContainer dijitLayoutContainer" widgetid="dijit_layout_BorderContainer_0" style="padding: 0px; width: 275px; height: 300px;">
<div id="dijit_layout_ContentPane_1" class="dijitContentPane dijitBorderContainerNoGutter-child dijitBor…nerNoGutterPane dijitAlignCenter dijitContentPaneSingleChild" widgetid="dijit_layout_ContentPane_1" style="left: 0px; top: 0px; position: absolute; width: 275px; height: 300px;">
<div id="pgObjectSelector_osInstance" class="xwtobjectselector" minheight="100" minwidth="220" data-dojo-attach-point="osNode" widgetid="pgObjectSelector_osInstance" style="cursor: default; width: 273px; height: 298px;">
<div id="xwt_widget_objectselector__Titlebar_0" class="xwtOsTitlebar" minwidth="100" data-dojo-attach-point="titleBar" widgetid="xwt_widget_objectselector__Titlebar_0"></div>
<div class="xwtobjectselectorcontents xwtOSDataReady" data-dojo-attach-point="osContents">
<div class="xwtObjectSelectorToolbars" data-dojo-attach-point="toolbars">
<div id="xwt_widget_objectselector__ObjectSelectorToolbar_0" class="xwtOsToolbar" data-dojo-attach-point="ButtonToolbar" minwidth="100" data-dojo-type="xwt.widget.toolbar.LayoutToolbar" widgetid="xwt_widget_objectselector__ObjectSelectorToolbar_0" style="display: none;"></div>
<div id="xwt_widget_filtertoolbar_FilterToolbar_0" class="xwtFilterToolbar" widgetid="xwt_widget_filtertoolbar_FilterToolbar_0" style="width: 273px;">
<div class="xwtFilterbarLeft" data-dojo-attach-point="SearchLeftGroup"></div>
<div class="xwtFilterbarCenter" data-dojo-attach-point="SearchCenterGroup">
<div class="xwtFilterSearchIcon icon-cisco-search" title="Search" tabindex="0" data-dojo-attach-point="searchButton">
<div class="xwt-ButtonSearchTextHighContrast" data-dojo-attach-point="searchTextHighCont"></div>
<span class="xwtFilterSearchText" data-dojo-attach-point="searchText"></span>
</div>
<span class="dijit dijitReset dijitInline xwtFilterDownButton xwtFilterDownIcon xwtFilterbarDropdownOff" widgetid="dijit_form_DropDownButton_3">
<span class="dijitReset dijitInline dijitButtonNode" data-dojo-attach-point="_buttonNode" data-dojo-attach-event="ondijitclick:__onClick"></span>
<input class="dijitOffScreen" type="button" aria-hidden="true" role="presentation" data-dojo-attach-point="valueNode" data-dojo-attach-event="onclick:_onClick" tabindex="-1" value=""></input>
</span>
<div id="widget_dijit_form_TextBox_1" class="dijit dijitReset dijitInline dijitLeft xwtFilterSearchBox dijitTextBox" role="presentation" widgetid="dijit_form_TextBox_1" style="width: 185px;">
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_TextBox_1" class="dijitReset dijitInputInner" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" tabindex="0" value=""></input>
<span class="dijitPlaceHolder dijitInputField">
Search All
</span>
</div>
</div>
<div class="xwtFilterClearIcon" data-dojo-attach-event="ondijitclick: _clearIconClicked" tabindex="0" data-dojo-attach-point="closeButton"></div>
<div class="xwtClear"></div>
</div>
<div class="xwtFilterbarRight" data-dojo-attach-point="SearchRightGroup"></div>
<div class="xwtAdvFilterButton" data-dojo-attach-point="advancedFilter"></div>
<div class="xwtClear"></div>
</div>
<div id="dijit_layout_ContentPane_0" class="dijitContentPane xwtOsScopeTabs" dolayout="true" minwidth="100" data-dojo-type="dijit/layout/ContentPane" data-dojo-attach-point="scopeTabs" widgetid="dijit_layout_ContentPane_0"></div>
<div id="xwt_widget_objectselector__SelectionDisplayBar_0" class="xwtOsSelectionBar" minwidth="100" data-dojo-attach-point="selectionBar" widgetid="xwt_widget_objectselector__SelectionDisplayBar_0" style="width: 268px;"></div>
</div>
<div id="dijit_layout_StackContainer_0" class="xwtobjectselectorview dijitStackContainer dijitContainer dijitLayoutContainer xwtOSDataReady xwtOsStackContainer" dolayout="true" data-dojo-attach-point="containerNode" widgetid="dijit_layout_StackContainer_0" style="width: 273px; height: 214px;"></div>
</div>
<div class="resizeHandleBoth" data-dojo-attach-point="resizeHandleAP" style="display: none;"></div>
<div class="xwtOsFooter"></div>
<div class="xwtOsLeftShadow"></div>
<div class="xwtOsRightShadow"></div>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="xwtPopoverFooter" data-dojo-attach-point="footer"></div>
</div>
<!--
Added connector attach point
-->
<div class="dijitTooltipConnector" data-dojo-attach-point="connector" wairole="presentation" style="left: 8px;"></div>
<div class="xwtPopoverLoader icon-spinner icon-spin" data-dojo-attach-point="loader" style="bottom: 139.333px; left: 153.5px; display: none;"></div>
</div>
</div>
Ok, first at all, if you need to set any text to this field, you can make div with:
id => 'pgObjectSelector_Popover' with JavaScript, using execute_script: #browser.execute_script("document.getElementById('pgObjectSelector_Popover').style.display = 'block';"), after, this pop-up have just one text_field so, you can do: #browser.div(pgObjectSelector_Popover).text_field.set 'ethernet'
Second,
#browser.div(:class=>/DownArrowButton/).when_present.click
#browser.div(:id=>'pgObjectSelector_Popover').text_field.set 'ethernet'
I have closed "Current Users" portlet from the demo installation and now can't open it back -- there is no such a portlet in a list.
How one can have it back on page?
Thanks.
The "Current Users" portlet is in fact just a "Web Content Display" portlet that's been renamed. So if you add a "Web Content Display" portlet on to your page and set then find the piece of Web Content called: "Welcome Login" (it's ID on mine was 10232, but this may be different for you) and set that as the content to be displayed you'll get it back. Or you can add a new piece of web content with the code below:
<p><style type="text/css"> .loginuser { margin-top:5px; width:100%; display:block; text-decoration:none; padding: 2px; padding-bottom: 10px; } .loginuser h2 { margin:0; font-size:14px; /*text-align:center;*/ } .loginuser a { display:block; padding-left: 20px; margin-left: 95px; margin-top: 2px; } .loginuser img { padding:2px; margin-right: 5px; } .loginuser:hover { background-color: #CED9E2; /*cursor:pointer;*/ } .express_login { background: url("/html/icons/login.png") no-repeat; } .public_pages { background: url("/html/themes/classic/images/common/view_tasks.png") no-repeat; } </style></p>
<form name="loginadmin" method="post" action="/web/guest/home">
<input type="hidden" value="58" name="p_p_id" /> <input type="hidden" value="1" name="p_p_lifecycle" /> <input type="hidden" value="view" name="p_p_mode" /> <input type="hidden" value="maximized" name="p_p_state" /> <input type="hidden" value="/login/login" name="_58_struts_action" /> <input type="hidden" value="bruno#7cogs.com" name="_58_login" /> <input type="hidden" value="bruno" name="_58_password" />
<div title="Login: bruno#7cogs.com, Password: bruno" class="loginuser">
<div style="float: left; padding-right: 4px;" class="user-profile-image"><img width="80" class="avatar" alt="" src="/image/user_portrait?screenName=bruno&companyId=10112&t=1228845375900" /></div>
<h2>Bruno (Admin)</h2>
<div>The admin has full control over the entire portal, allowing modification and creation of users, communitities, and roles. <a class="public_pages" href="/web/bruno">View bruno's public page</a> <a onclick="document.loginadmin.submit();return false;" class="express_login" href="#">Login as bruno</a></div>
</div>
</form>
<form name="loginrich" method="post" action="/web/guest/home">
<input type="hidden" value="58" name="p_p_id" /> <input type="hidden" value="1" name="p_p_lifecycle" /> <input type="hidden" value="view" name="p_p_mode" /> <input type="hidden" value="maximized" name="p_p_state" /> <input type="hidden" value="/login/login" name="_58_struts_action" /> <input type="hidden" value="richard#7cogs.com" name="_58_login" /> <input type="hidden" value="richard" name="_58_password" />
<div title="Login: richard#7cogs.com, Password: richard" class="loginuser">
<div style="float: left; padding-right: 4px;" class="user-profile-image"><img width="80" class="avatar" alt="" src="/image/user_portrait?screenName=richard&companyId=10112&t=1228845375871" /></div>
<h2>Richard Publisher</h2>
<div>Richard has article submission rights for the content management system. <a class="public_pages" href="/web/richard">View richard's public page</a> <a onclick="document.loginrich.submit();return false;" class="express_login" href="#">Login as richard</a></div>
</div>
</form>
<form name="loginmichelle" method="post" action="/web/guest/home">
<input type="hidden" value="58" name="p_p_id" /> <input type="hidden" value="1" name="p_p_lifecycle" /> <input type="hidden" value="view" name="p_p_mode" /> <input type="hidden" value="maximized" name="p_p_state" /> <input type="hidden" value="/login/login" name="_58_struts_action" /> <input type="hidden" value="michelle#7cogs.com" name="_58_login" /> <input type="hidden" value="michelle" name="_58_password" />
<div title="Login: michelle#7cogs.com, Password: michelle" class="loginuser">
<div style="float: left; padding-right: 4px;" class="user-profile-image"><img width="80" class="avatar" alt="" src="/image/user_portrait?screenName=michelle&companyId=10112&t=1228845375823" /></div>
<h2>Michelle Editor</h2>
<div>Michelle has control over the staging and layout of all articles as well as publishing rights for workflow and the content management system. <a class="public_pages" href="/web/michelle">View michelle's public page</a> <a onclick="document.loginmichelle.submit();return false;" class="express_login" href="#">Login as michelle</a></div>
</div>
</form>
<form name="loginjohn" method="post" action="/web/guest/home">
<input type="hidden" value="58" name="p_p_id" /> <input type="hidden" value="1" name="p_p_lifecycle" /> <input type="hidden" value="view" name="p_p_mode" /> <input type="hidden" value="maximized" name="p_p_state" /> <input type="hidden" value="/login/login" name="_58_struts_action" /> <input type="hidden" value="john#7cogs.com" name="_58_login" /> <input type="hidden" value="john" name="_58_password" />
<div title="Login: john#7cogs.com, Password: john" class="loginuser">
<div style="float: left; padding-right: 4px;" class="user-profile-image"><img width="80" class="avatar" alt="" src="/image/user_portrait?screenName=john&companyId=10112&t=1228845375887" /></div>
<h2>John Regular User</h2>
<div>John is a user with minimum rights within the portal.
<div><a class="public_pages" href="/web/john">View john's public page</a> <a onclick="document.loginjohn.submit();return false;" class="express_login" href="#">Login as john</a></div>
</div>
</div>
</form>
Hope this helps!