Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script using twice #3

Open
daisys77 opened this issue Apr 7, 2018 · 0 comments
Open

script using twice #3

daisys77 opened this issue Apr 7, 2018 · 0 comments

Comments

@daisys77
Copy link

daisys77 commented Apr 7, 2018

i am trying to use your script on my app for creating cotact and booking form. my problem is only 1 code will work and other wont work. i changed the ids still wont work. can you please help.

i havent fully editted them for my needs. first need to work.

thank you

heres my code
booking form//
// Reference boks collection
var boksRef = firebase.database().ref('boks');

// Listen for form submit
document.getElementById('contactForms').addEventListener('submit', submitForm);

// Submit form
function submitForm(e){
e.preventDefault();

// Get values
var name = getInputVal('name');
var company = getInputVal('company');
var email = getInputVal('email');
var phone = getInputVal('phone');
var message = getInputVal('message');

// Save bok
savebok(name, company, email, phone, message);

// Show alert
document.querySelector('.alert').style.display = 'block';

// Hide alert after 3 seconds
setTimeout(function(){
    document.querySelector('.alert').style.display = 'none';
},3000);

// Clear form
document.getElementById('contactForms').reset();

}

// Function to get get form values
function getInputVal(id){
return document.getElementById(id).value;
}

// Save bok to firebase
function savebok(name, company, email, phone, message){
var newbokRef = boksRef.push();
newbokRef.set({
name: name,
company:company,
email:email,
phone:phone,
message:message
});
}

//contact form
// Initialize Firebase (ADD YOUR OWN DATA)

// Reference boks collection
var bokesRef = firebase.database().ref('bokes');

// Listen for form submit
document.getElementById('contacted').addEventListener('submit', submitForms);

// Submit form
function submitForms(e){
e.preventDefault();

// Get values
var name = getInputVal('name');
var company = getInputVal('company');
var email = getInputVal('email');
var phone = getInputVal('phone');
var message = getInputVal('message');

// Save bok
saveboke(name, company, email, phone, message);

// Show alert
document.querySelector('.alert').style.display = 'block';

// Hide alert after 3 seconds
setTimeout(function(){
    document.querySelector('.alert').style.display = 'none';
},3000);

// Clear form
document.getElementById('contacted').reset();

}

// Function to get get form values
function getInputVal(id){
return document.getElementById(id).value;
}

// Save bok to firebase
function saveboke(name, company, email, phone, message){
var newbokeRef = bokesRef.push();
newbokeRef.set({
name: name,
company:company,
email:email,
phone:phone,
message:message
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant