According to the docs and code i have looked at, this is how forms are created to add card or accept cards
var style = {
base: {
fontSize: "16px",
color: "#32325d",
fontFamily:
"-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif",
fontSmoothing: "antialiased",
"::placeholder": {
color: "rgba(0,0,0,0.4)"
}
}
};
var card = elements.create("card", { style: style });
card.mount("#card-element");
this is according to the docs https://stripe.com/docs/stripe-js and the code example given https://github.com/stripe-samples/saving-card-without-payment/blob/master/client/script.js
How can i format the new forms so that i have the email,card holder name, card number,expiration and cvv on a different line?
I am using twitter bootstrap. Also how can i leave out the postal code part?
I just recently figured this out for a project I am working on and it was more challenging than I was expecting. The example below is creating a payment method for a metered billing scenario. The hardest thing for me to comprehend during the learning process was in the createPaymentMethod you will notice that it is only passed the cardNumber element and then the stripe library figures out the other elements automatically.
HTML:
<div class="row">
<div class="col-md-6 mb-3">
<label for="cc-name">Name on card</label>
<input type="text" class="form-control" id="cc-name" placeholder="" required>
<small class="text-muted">Full name as displayed on card</small>
<div class="invalid-feedback">
Name on card is required
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div id="card-number" style="border:2px solid gray;"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div id="card-exp" style="border:2px solid gray;"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div id="card-cvc" style="border:2px solid gray;"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<button id="submit-button" type="button">
<div class="spinner hidden" id="spinner"></div>
<span id="button-text">Pay</span>
</button>
</div>
</div>
Javascript:
$(document).ready(function () {
// Create a Stripe client
var stripe = Stripe('YOUR KEY');
// Create an instance of Elements
var elements = stripe.elements({
locale: 'auto'
});
let displayError = document.getElementById('card-error');
var style = {
base: {
color: "#32325d",
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: "antialiased",
fontSize: "16px",
"::placeholder": {
color: "#aab7c4"
}
},
invalid: {
color: "#fa755a",
iconColor: "#fa755a"
}
};
var cardNumber = elements.create("cardNumber", { style: style });
cardNumber.mount("#card-number");
var cardExp = elements.create("cardExpiry", { style: style });
cardExp.mount("#card-exp");
var cardCvc = elements.create("cardCvc", { style: style });
cardCvc.mount("#card-cvc");
cardNumber.on('change', showCardError);
cardExp.on('change', showCardError);
cardCvc.on('change', showCardError);
function showCardError(event) {
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
}
$("#submit-button").on("click", function () {
createPaymentMethod(cardNumber, 'CUSTOMER ID', 'PRODUCT ID');
});
function createPaymentMethod(cardElement, customerId, priceId) {
return stripe
.createPaymentMethod({
type: 'card',
card: cardElement,
billing_details: {
name: $('#cc-name').val()
}
})
.then((result) => {
if (result.error) {
displayError.textContent = result.error;
} else {
console.log('SUCCESS');
console.log(result);
}
});
}
});
Related
I would like to add a percentage value per slice of the doughnut chart, but I can't seem to figure out how. Also the data is dynamic not static, which means if there is another item added it needs to be able to recalculate and give accurate percentage per slice. This is the code below which shows the component of home, where there is data being fetched from the server side and getting the results. Then there is a variable called pie data results that maps and stores the occupation and values, and that is being passed as a prop down in the victory pie component.
import React, { Fragment, useState, useEffect } from "react";
//import DoughnutChart from "./DoughnutChart";
//import { Doughnut } from "react-chartjs-2";
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
//import { toast } from "react-toastify";
import "./pagecss/home.css";
import * as V from "victory";
import { VictoryPie } from "victory";
// import pieChartBasic from "./DoughnutChart";
// import { Doughnut } from "react-chartjs-2";
// import { FontAwesomeIcon } from "#fontawesome-free-solid";
// import { encryptStorage } from "./encrypt";
const Home = ({ setAuth }) => {
const [username, setUsername] = useState("");
const [user_id, setuserid] = useState("");
const [occ, setOcc] = useState([]);
// const [personalForm, setpersonalForm] = useState([]);//
// const [Pform, setform] = useState(false);
async function getUsername() {
try {
const response = await fetch("http://localhost:4001/home/", {
method: "GET",
//pass token with localstorage because it is stored in the header
headers: { token: localStorage.token },
});
const parseRes = await response.json();
// setpersonalForm(parseData);
setUsername(parseRes.username);
setuserid(parseRes.user_id); //
// const encryptStorage = new EncryptStorage('secret-key');
// encryptStorage.setItem("user_id", parseRes.user_id);
console.log(parseRes);
} catch (err) {
console.error(err.message);
}
try {
const response = await fetch("http://localhost:4001/results/occ", {
method: "GET",
//pass token with localstorage because it is stored in the header
headers: { token: localStorage.token },
});
const parseRes = await response.json();
// setpersonalForm(parseData);
setOcc(parseRes.data.occupationResults);
console.log(parseRes.data.occupationResults);
} catch (err) {
console.error(err.message);
}
}
//going to make a request when we get to this component, this is for getting from database
useEffect(() => {
getUsername();
}, []);
// const PIEDATAVALUES = occ.map((occupation) =>
// { "x"= occupation.occupation,
// "y"= occupation.values
// },
// );
// console.log(PIEDATAVALUES);
const result = [];
const piedataresults = occ.reduce((a, item) => {
result.push({ x: item.occupation, y: item.values });
return result;
}, []);
//console.log(piedataresults);
return (
<div>
<div className="container">
<div className="row">
<div className="col-md-4 col-sm-12 d-flex justify-content-center">
<div className="card-body text-center text-white">
<i className="fa-solid fa-bullseye fa-6x my-3 "></i>
<h2 className="card-title mb-4">Card Title</h2>
<p className="card-text">
Our Mission is to help the community out by helping people with
mental health issues
</p>
</div>
</div>
<div className="col-md-4 col-sm-12 d-flex justify-content-center">
<div className="card-body text-center text-white">
<i className="fa-solid fa-glasses fa-6x text-center my-3 "></i>
<h2 className="card-title mb-4">Card Title</h2>
<p className="card-text">
Our Mission is to help the community out by helping people with
mental health issues
</p>
</div>
</div>
<div className="col-md-4 col-sm-12 d-flex justify-content-center">
<div className="card-body text-center text-white pb-4">
<i className="fa-solid fa-hand-holding-medical fa-6x text-center my-3 "></i>
<h2 className="card-title mb-4">Card Title</h2>
<p className="card-text">
Our Mission is to help the community out by helping people with
mental health issues
</p>
</div>
</div>
</div>
</div>
<div className="row mb-5 " id="piechartrow">
<div
className="col-md-6 col-sm-12 text-white text-center "
id="pietext"
>
<p id="pietext">
It is a long established fact that a reader will be distracted by
the readable content of a page when looking at its layout. The point
of using Lorem Ipsum is that it has a more-or-less normal
distribution of letters, as opposed to using 'Content here, content
here', making it look like readable English.
</p>
</div>
<div className="col-md-6 col-sm-12 mt-3" id="piechartcol">
<svg viewBox="-15 -25 450 350" id="piechart">
<g transform={"translate(0, -75)"}>
<VictoryPie
colorScale={[
"#6680FF",
"#DFFF00",
"#DF4E4F",
"#FFB600",
"#eeaaaa",
"#23B936",
]}
name="pie"
width={350}
innerRadius={75}
standalone={false}
style={{
labels: { fill: "white", fontSize: 13, padding: 14 },
}}
data={piedataresults}
/>
</g>
</svg>
</div>
</div>
<div className="container-fluid">
<div className="row justify-content-around">
<div
className="card col-lg-5 col-md-6 col-sm-12 d-flex justify-content-center mb-5 "
id="CardOne"
>
<img
src={require("./pictures/ProPic.jpg")}
className="card-img-top"
id="pictureOne"
alt="..."
/>
<div className="card-body text-center text-white">
<h2 className="card-title mb-4">Alexey Aulov</h2>
<p className="card-text">
Hi my name is Alexey Aulov I am a senior at College of Staten
Island studying Information System and Informatics. I had the
original idea of Essential Health after I witnessed that
sometimes the best way for people to get mental help is to have
Therapist that can relate to you as much as possible to help you
out. Helping people gives me the most gratitude in life.
</p>
</div>
</div>
<div
className="card col-lg-5 col-md-6 col-sm-12 d-flex justify-content-center mb-5 "
id="CardTwo"
>
<img
src={require("./pictures/JLTwo.jpg")}
className="card-img-top"
alt="..."
id="pictureTwo"
/>
<div className="card-body text-center text-white">
<h2 className="card-title mb-4">Jonathan Leibovici</h2>
<p className="card-text">
Our Mission is to help the community out by helping people with
mental health issues
</p>
</div>
</div>
</div>
</div>
</div>
);
};
export default Home;
I am new to angular when I was trying to put the form validation to the text field form was present inside *ngFor loop, So validation is working but it shows to every field but I want validation the particular field only , so please help me How to put the validation to the particular form field.
**HTML**
<div class="container" *ngFor="let post of posts; let i = index">
<div class="row">
<div class="col-md-12" style="display: block; ">
<form [formGroup]="commentForm" method="post" enctype="multipart/form-data" (ngSubmit)="comment_Submit(post.user_id, post.post_id,
commentForm)">
<div class="form-group">
<input type="text" class="form-control" name="comment{{i}}" formControlName="comment" id="comment"
placeholder="Enter comments" cols="40" rows="5" spellcheck="true"
style="width:100%; height: auto; border: 1px solid #ada5a5; border-radius: 4px; outline: none; user-select: text; white-space: pre-wrap; overflow-wrap: break-word; "
[ngClass]="{'form-control': true,
'is-invalid': !f.comment.valid,
'is-valid':f.comment.valid}">
<div *ngIf="f.comment.errors?.minlength && f.comment.touched" class="text-danger">Comment
should be at
least 2 characters.</div>
</div>
<button type="submit" class="btn-sm btn-success" [disabled]="!commentForm.valid">Comment</button>
</form>
</div>
</div>
</div>
**TypeScript**
export class PostsComponent implements OnInit {
get f() { return this.commentForm.controls; }
constructor(private userService: UserService, private formBuilder: FormBuilder,
private alerts: AlertsService) {
this.commentFormValidation();
}
commentForm: FormGroup;
ngOnInit() { }
commentFormValidation() {
this.commentForm = this.formBuilder.group({
comment: [null, [Validators.required, Validators.minLength(2)]]
});
}
Your posts all share the one and same form. If you have n amount of posts, you need n amount of forms. We can achieve this by creating an array (just a JS array) of formgroups, the same length that your posts array is...
formsArr = [];
constructor(private fb: FormBuilder) { }
ngOnInit() {
this.posts.forEach((x) => {
this.formsArr.push(this.fb.group({
comment: this.fb.control('', [Validators.required, Validators.minLength(2)])
}))
})
}
Then in your template you iterate formsArr. You probably need access to some stuff in your posts array... so we add the index in iteration, therefore you can access the specific post with posts[i]. Also remove method="post" from your form:
<div *ngFor="let a of formsArr; let i = index">
<form [formGroup]="a" (ngSubmit)="onSubmit(a.value, posts[i].user_id)">
<input formControlName="comment" />
<small *ngIf="a.hasError('minlength', 'comment') && a.get('comment').touched">
Needs to be 2 letters
</small>
<button type="submit" [disabled]="!a.valid">Comment</button>
</form>
</div>
StackBlitz
I am very new to email integration for web applications so please bear with me in this situation...
I am working on a site for a startup company and I currently have a vue.js front end app using the webpack template which contains a contact form for clients to contact the company. I also have a node.js back end application which receives the data from the front end application using websocket which I intend to use to send emails with the clients information to the startup company. My aim is to be able to send emails without using the transporter email address , but use the email address in the from: object instead. I would also like to make sure my email doesnt appear in the spam folder.
In this example I tried using nodemailer but the email does not show the client s'email and the email appears in the junk folder.
my front end vue.js application:
<template>
<main id="fullpage">
<b-form #submit.prevent="validateForm($event)" id="contactForm" autocomplete="off"
method="post">
<section class="section contactForm">
<b-form-row>
<h1>{{clientMsg}}</h1>
</b-form-row>
<b-form-row>
<b-col>
<input type="radio" name="client" value="individual" #click="IndvClient"> <label for="individual">an individual?</label>
</b-col>
<b-col>
<input type="radio" name="client" value="company" #click="CorporateClient" > <label for="company">a company?</label>
</b-col>
<b-col cols="12">
<a class="steps text-right next" :href="sectionLinks.emailLink">Next</a>
</b-col>
</b-form-row>
</section>
<section class="section contactForm">
<b-row no-gutters>
<b-col>
<input type="email" id="usrEmail" placeholder="Email address..." class="text-center"
:pattern="emailValidation" required v-model="email" #mouseout="isValidEmail($event)" autocomplete="off">
</b-col>
</b-row>
<b-row no-gutters>
<b-col cols="6">
Previous
</b-col>
<b-col cols="6">
<a class="steps text-right next" :href="sectionLinks.nameLink">Next</a>
</b-col>
</b-row>
</section>
<section class="section contactForm">
<input type="text" name="usrName" id="usrName" placeholder="Name..." class="text-center"
required :pattern="textValidation" v-model="name" #mouseout="isValidName($event)" autocomplete="off">
<b-row no-gutters>
<b-col cols="6">
Previous
</b-col>
<b-col cols="6">
<a class="steps text-right next" :href="sectionLinks.titleLink">Next</a>
</b-col>
</b-row>
</section>
<section class="section contactForm">
<input type="text" name="msgTitle" id="msgTitle" placeholder="Title of the message..."
class="text-center" v-model="messageTitle" required :pattern="textValidation"
#mouseout="isValidTitle($event)" autocomplete="off">
<b-row no-gutters>
<b-col cols="6">
Previous
</b-col>
<b-col cols="6">
<a class="steps text-right next" :href="sectionLinks.msgLink" >Next</a>
</b-col>
</b-row>
</section>
<section class="section contactForm">
<b-row no-gutters>
<b-col cols="12">
<textarea name="" id="msgContent" cols="100" rows="7"
placeholder="Message..." v-model="message" required
#mouseout="isValidMsg($event)"></textarea>
</b-col>
</b-row>
<b-row no-gutters>
<b-col cols="6">
Previous
</b-col>
<b-col cols="6">
<a class="steps text-right next" :href="sectionLinks.msgSummaryLink">Next</a>
</b-col>
</b-row>
</section>
<section class="section contactForm formSummary">
<ul class="prevFormLinks">
<li v-for="section in previousLinks">
<a :href="section.link">{{section.name}}</a>
</li>
</ul>
<b-form-row>
<p>{{clientMsg}}</p>
</b-form-row>
<b-form-row>
<b-col>
<input type="radio" name="userClient" value="individual"> <label for="individual">an individual?</label>
</b-col>
<b-col>
<input type="radio" name="userClient" value="company"> <label for="company">a company?</label>
</b-col>
</b-form-row>
<b-form-row>
<b-col>
<h2>Your email:</h2>
</b-col>
<b-col>
<p>{{email}}</p>
</b-col>
</b-form-row>
<b-form-row>
<b-col>
<h2>Name:</h2>
</b-col>
<b-col>
<p>{{name}}</p>
</b-col>
</b-form-row>
<b-form-row>
<b-col>
<h4>Title of the message:</h4>
</b-col>
<b-col>
<p>{{messageTitle}}</p>
</b-col>
</b-form-row>
<b-form-row>
<b-col cols="5" id="msgSummary">
<p>{{message}}</p>
</b-col>
</b-form-row>
<b-form-row>
<b-col cols="12">
<input type="submit" value="Submit!">
</b-col>
</b-form-row>
</section>
</b-form>
</main>
</template>
<script>
import fullpage from 'fullpage.js'
import $ from "jquery"
/**
Make sure you can then send an email
Replace the jQuery animations with anime.js or another way of animating.
There are no previous buttons for the summary section.
*/
export default {
data(){
return {
"clientMsg":this.$store.state.contact.TypeOfClientMsg,
"name":"",
"email":"",
"messageTitle":"",
"message":"",
"emailValidation":"^([a-zA-Z0-9_\-\.]+)#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
"textValidation":"[a-zA-Z ]+",
"sectionLinks":{
"clientLink":"#clientType",
"emailLink":"#email",
"nameLink": "#name",
"titleLink":"#title",
"msgLink":"#message",
"msgSummaryLink":"#messageSummary"
},
"previousLinks":[
{
"link":"#clientType",
"name":"Client"
},
{
"link":"#email",
"name":"Email"
},
{
"link":"#name",
"name":"Name"
},
{
"link":"#title",
"name":"Title"
},
{
"link":"#message",
"name":"Message"
}
],
"companyEmail":"salay777#hotmail.co.uk"
}
},
methods:{
IndvClient:function(){
let ind = document.querySelectorAll('input[value="individual"]');
let company = document.querySelectorAll('input[value="company"]'),
goToEmail = document.querySelector('a[href="#email"]');
(ind[0].checked == true)? ind[1].checked = true : ind[1].checked = false;
$(goToEmail).fadeIn();
},
CorporateClient:function(){
let ind = document.querySelectorAll('input[value="individual"]');
let company = document.querySelectorAll('input[value="company"]'),
goToEmail = document.querySelector('a[href="#email"]');
(company[0].checked == true)? company[1].checked = true : company[1].checked = false;
$(goToEmail).fadeIn();
},
isValidEmail:function(e){
let goToName = document.querySelector('a[href="#name"]');
(e.target.checkValidity())? $(goToName).fadeIn() : $(goToName).fadeOut();
},
isValidName:function(e){
let goToTitle = document.querySelector('a[href="#title"]');
(e.target.checkValidity())? $(goToTitle).fadeIn() : $(goToTitle).fadeOut();
},
isValidTitle:function(e){
let goToMsg = document.querySelector('a[href="#message"]');
(e.target.checkValidity())? $(goToMsg).fadeIn() : $(goToMsg).fadeOut();
},
isValidMsg:function(e){
let goToSummary = document.querySelector('a[href="#messageSummary"]');
(e.target.checkValidity())? $(goToSummary).fadeIn() : $(goToSummary).fadeOut();
},
validateForm:function(e){
let idvClient = document.querySelector('input[value="individual"]'),
corporateClient = document.querySelector('input[value="company"]'),
usrEmail = document.getElementById('usrEmail'), usrName = document.
getElementById('usrName'), msgTitle = document.getElementById('msgTitle'),
msgContent = document.getElementById('msgContent'),
socket = io.connect('http://localhost:5000/');
if(idvClient.checked !== corporateClient.checked){
console.log('client has been checked');
if(usrEmail.checkValidity() == false || usrName.checkValidity() == false ||
msgTitle.checkValidity() == false || msgContent.checkValidity() == false){
e.preventDefault();
} else {
let email = {
client :"",
email: this.email,
name: this.name,
title: this.messageTitle,
message: this.message
};
if(idvClient.checked){
email.client = "[IDV]";
}
if(corporateClient.checked){
email.client = "[CO]";
}
socket.emit('email',email);
alert('submitted!');
}
} else {
console.log('you need to select a client type');
e.preventDefault();
}
}
},
mounted(){
let idvClient = document.querySelector('input[value="individual"]'),
corporateClient = document.querySelector('input[value="company"]'),
goToEmail = document.querySelector('a[href="#email"]'), form =
document.querySelector('form');
form.setAttribute('autocomplete', 'off');
if(idvClient.checked == corporateClient.checked){
goToEmail.style.display = 'none';
}
}
};
</script>
<style>
html body #fullpage {
background-color:#383838 !important;
background-image: none !important;
}
html, body,#fullpage {
overflow: hidden !important;
}
.fp-tableCell{
text-align:center;
display:flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.contactDetails .row {
margin:0px;
}
.contactForm .form-row {
min-width:500px;
justify-content:center;
}
.contactForm .form-row a, .contactForm .row a {
margin: 60px;
text-decoration: none;
color: #f4f4f4;
font-size: 36px;
font-weight: 100;
transition: color .5s, font-size .2s;
}
.contactForm .form-row a:hover, .contactForm .row a:hover {
color:orange;
font-size:40px;
}
#menu {
display: none !important;
}
button {
margin-top:20px;
}
h1, h2, h3 , h4 {
font-weight:100;
}
.next {
display: none;
}
#msgSummary {
word-wrap: break-word;
text-align:left;
}
.formSummary, .formSummary h2 , .formSummary h4,
.formSummary p {
text-align:left !important;
}
.prevFormLinks {
position:absolute;
left:30px;
text-align:left;
margin:0px !important;
padding:0px;
color:white !important;
}
.prevFormLinks a {
font-size:20px !important;
margin:0px!important;
padding: 0px !important;
text-decoration: none;
color: white !important;
font-weight:100;
transition: font-size .25s, color 2s;
}
.prevFormLinks a:hover {
font-size: 25px !important;
color: orange !important;
}
</style>
my email module for my back end application:
let emailModule = (function(){
let nodemailer = require('nodemailer'), mailOptions = {from:'', to:'', subject:'', text:''};
let transporter = nodemailer.createTransport({
service : 'gmail',
auth: {
user:'projectgorillatransporter#gmail.com',
pass'*******'
}
});
let setMailOptions = (from, to, subject, text)=>{
return new Promise((resolve, reject)=>{
mailOptions.from = from;
mailOptions.to = to;
mailOptions.subject = subject;
mailOptions.text = text;
console.log(mailOptions);
resolve(mailOptions);
reject(Error('the mailOPtions object was not created'));
});
};
let sendEmail = (mailOptions)=>{
transporter.sendMail(mailOptions, (err, info)=>{
if (err) {
console.log(err);
} else {
console.log('Email sent: ' + info.response);
}
});
}
return {
send : sendEmail,
setMailOptions : setMailOptions
}
})(); // end of the email module
module.exports = emailModule;
my node.js server in charge of handling data:
let express = require('express'), app = express(), path = require('path'),
socket = require('socket.io'), emailModule = require('./email.js');
let server = app.listen(5000, ()=>{
console.log('listening to requests...');
});
let io = socket(server);
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
io.on('connection', (socket)=>{
console.log('made a connection!');
socket.on('email', (data)=>{
/**
* Here you need to set your email options which includes the clients email, destination email,
* subject and the text (the email content).
*/
emailModule.setMailOptions(data.email,'salay777#hotmail.co.uk', data.client + ' ' + '(' +
data.name + ')' + ' ' + data.title, data.message).then((mailOpts)=>{
emailModule.send(mailOpts);
console.log('email has been sent!');
});
});
});
There is email-templates and sendmail, though nodemailer is very easy. Have you taken a look at either of the first two packages?
This is my View..
<div style="float: left; width: 450px; text-align:left; margin-left:80px">
<div class="row">
<div class="label" style="float: left; width: 80px">Date From: </div>
<div class="control">
#Html.EditorFor(model => model.DateFrom, new { ID = "datefrom" })
#Html.ValidationMessageFor(model => model.DateFrom, null, new { style = "color: red" })
</div>
</div>
<div class="row">
<div class="label" style="float: left; width: 80px">Date To: </div>
<div class="control" >
#Html.EditorFor(model => model.DateTo, new { ID = "dateto" })
#Html.ValidationMessageFor(model => model.DateTo, null, new { style = "color: red" })
</div>
</div>
<div><input type="checkbox" id="relative" name="relative" onclick="validate()" />Is Relative</div>
</div>
And this is my js function:
function validate() {
if (document.getElementById('relative').checked) {
document.getElementById('#Html.IdFor(model => model.DateFrom)').disabled = true;
document.getElementById('#Html.EditorFor(model => model.DateFrom, new { #Value = DateTime.Now })');
document.getElementById('#Html.IdFor(model => model.DateTo)').disabled = true;
document.getElementById('#Html.EditorFor(model => model.DateTo, new { #Value = DateTime.Now })');
} else {
document.getElementById('#Html.IdFor(model => model.DateFrom)').disabled = false;
document.getElementById('#Html.IdFor(model => model.DateTo)').disabled = false;
}
}
How can assign a default value (DateTiem.Now) to Html.EditorFor? Thanks a lot for your Help!!!
No Body has replied to this question in a long time. If somebody else trying to solve the similar issue.
try this in your Javascript.
document.getElementById('#Html.IdFor(model => model.Draw)')
I need to use multiple stream instances with jPlayer using this player. By default it didn't so I tried to make several changes but still can't get it work. First player works but it plays all the other streams together and the second player can't be triggered at all. Any idea? My code is as follows:
SCRIPT
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(){
var stream = {
title: "ABC Jazz",
mp3: "http://listen.radionomy.com/abc-jazz"
},
ready = false;
jQuery("#jquery_jplayer_11").jPlayer({
ready: function (event) {
ready = true;
jQuery(this).jPlayer("setMedia", stream);
},
pause: function() {
jQuery(this).jPlayer("clearMedia");
},
error: function(event) {
if(ready && event.jPlayer.error.type === jQuery.jPlayer.error.URL_NOT_SET) {
// Setup the media stream again and play it.
jQuery(this).jPlayer("setMedia", stream).jPlayer("play");
}
},
swfPath: "js",
supplied: "mp3",
preload: "none",
wmode: "window",
keyEnabled: true
});
var stream2 = {
title: "Second",
mp3: "http://stream.x-x-x-x.com:1234/stream"
},
ready = false;
jQuery("#jquery_jplayer_12").jPlayer({
ready: function (event) {
ready = true;
jQuery(this).jPlayer("setMedia", stream2);
},
pause: function() {
jQuery(this).jPlayer("clearMedia");
},
error: function(event) {
if(ready && event.jPlayer.error.type === jQuery.jPlayer.error.URL_NOT_SET) {
// Setup the media stream again and play it.
jQuery(this).jPlayer("setMedia", stream2).jPlayer("play");
}
},
swfPath: "js",
supplied: "mp3",
preload: "none",
wmode: "window",
keyEnabled: true
});
});
//]]>
</script>
HTML
<div id="jquery_jplayer_11" class="jp-jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_0" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_0" preload="none"></audio>
</div>
<div id="jquery_jplayer_12" class="jp-jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_0" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_0" preload="none"></audio>
</div>
<div id="jp_container_1" class="jp-audio-stream">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li class="pp-li">play</li>
<li class="pp-li">pause</li>
<li class="mu-li">mute</li>
<li class="mu-li">unmute</li>
<li class="vo-li">max volume</li>
</ul>
<div class="jp-volume-bar" style="">
<div class="jp-volume-bar-value" style="width: 80%;"></div>
</div>
</div>
</div>
<div id="jp_container_2" class="jp-audio-stream">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li class="pp-li">play</li>
<li class="pp-li">pause</li>
<li class="mu-li">mute</li>
<li class="mu-li">unmute</li>
<li class="vo-li">max volume</li>
</ul>
<div class="jp-volume-bar" style="">
<div class="jp-volume-bar-value" style="width: 80%;"></div>
</div>
</div>
</div>
set
cssSelectorAncestor: "#jp_container_2"
cssSelectorAncestor: "#jp_container_1"
like this for all players and after the playlist options (that means at the bottom of the code )
$("#jplayer_inspector_1").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
$("#jplayer_inspector_2").jPlayerInspector({jPlayer:$("#jquery_jplayer_2")});
put like this for all-players then it will works , if not means put all the codes here then I will correct the errors