Skip to main content

Saving Multiple Values

I am able to save the value of one input on my web app, but now I am trying to save multiple input values. I want to save the user's email, phone, city, etc. How do I set that up in my javascript function that is linked to firebase? What I have currently is only saving the studio name. I have provided my code and a screenshot of the database and web app inputs below:

Firebase Real-Time Database: Firebase Real-Time Database

User Input Screenshot: enter image description here

HTML Code:

<!DOCTYPE html>
<html>
    <head>
        <!---Required meta tags--->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="CSS/editprofile.css">
        <script>"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"</script>
        <!---Required meta tags--->
    
        <!---Like Button JavaScript--->
        <script src="https://kit.fontawesome.com/f6dcf461c1.js" crossorigin="anonymous"></script>
        <!---Like Button JavaScript--->
    
        <!---Bootstrap CSS--->
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
        crossorigin="anonymous">
        <!---Bootstrap CSS--->
        
        <title>StudioPick</title>
        
    </head>
    <body>
        <header>
            <nav class="navbar navbar-expand-lg navbar-light">
                <div class="container-fluid">
                <a style="font-size: 45px; color: #A388E7;" class="navbar-brand" href="#"><strong>StudioPick</a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                        <li class="nav-item">
                        <a class="nav-link active" aria-curresnt="page" href="index.html">Home</a>
                        </li>
                        <li class="nav-item">
                        <a class="nav-link" href="#">Sign Up</a>
                        </li>
                        <li class="nav-item2">
                        <a class="nav-link" href="#">Login</a>
                        </li>
                    </ul>
                    </div>
                </div>
            </nav>
        </header>
        <form class="container py-5 h-100" id="studioForm">
            <div class="container">
                <main>
                  <div class="py-5 text-center">
                    <img class="d-block mx-auto mb-4" src="/docs/5.2/assets/brand/bootstrap-logo.svg" alt="" width="72" height="57">
                    <h2>Edit Profile</h2>
                    <p class="lead">Here is where you can change your profile settings and update your personal information.</p>
                  </div>
              
                  <div class="row g-5">
                    <div class="col-md-5 col-lg-4 order-md-last">
                      <h4 class="d-flex justify-content-between align-items-center mb-3">
                        <span>Your Profile Picure</span>
                      </h4>
                      
                      <div class="profile-img">
                        <img class="d-block mx-auto mb-4" id="profile-pic" src="Images/placeholder.png" alt="">
                      </div>
              
                      <form class="card p-2">
                        <div class="input-group">
                          <button type="submit" class="btn btn-secondary" id="uploadBtn">Upload</button>
                        </div>
                      </form>
                    </div>
                    <div class="col-md-7 col-lg-8">
                      <h4 class="mb-3">Personal Information</h4>
                      <form class="needs-validation" novalidate="">
                        <div class="row g-3">
                          <div class="col-sm-6">
                            <label for="firstName" class="form-label">First name</label>
                            <input type="text" class="form-control" id="ownerFirstName" placeholder="John" value="" required="">
                            <div class="invalid-feedback">
                              Valid first name is required.
                            </div>
                          </div>
              
                          <div class="col-sm-6">
                            <label for="lastName" class="form-label">Last name</label>
                            <input type="text" class="form-control" id="ownerLastName" placeholder="Doe" value="" required="">
                            <div class="invalid-feedback">
                              Valid last name is required.
                            </div>
                          </div>
              
                          <div class="col-12">
                            <label for="email" class="form-label">Email</label>
                            <input type="email" class="form-control" id="email" placeholder="you@example.com">
                            <div class="invalid-feedback">
                              Please enter a valid email address for updates.
                            </div>
                          </div>
              
                          <div class="col-12">
                            <label for="address" class="form-label">Address</label>
                            <input type="text" class="form-control" id="address" placeholder="1234 Main St" required="">
                            <div class="invalid-feedback">
                              Please enter your address.
                            </div>
                          </div>

                          <div class="col-md-3">
                            <label for="phoneNumber" class="form-label">Phone Number</label>
                            <input type="text" class="form-control" id="phoneNumber" placeholder="(123) 456-7890" required="">
                            <div class="invalid-feedback">
                              Phone number required.
                            </div>
                          </div>
              
                          <div class="col-md-5">
                            <label for="country" class="form-label">Country</label>
                            <select class="form-select" id="country" required="">
                              <option value="">Choose...</option>
                              <option>United States</option>
                            </select>
                            <div class="invalid-feedback">
                              Please select a valid country.
                            </div>
                          </div>
              
                          <div class="col-md-4">
                            <label for="state" class="form-label">State</label>
                            <select class="form-select" id="state" required="">
                              <option value="">Choose...</option>
                              <option>California</option>
                            </select>
                            <div class="invalid-feedback">
                              Please provide a valid state.
                            </div>
                          </div>

                          <div class="col-md-3">
                            <label for="city" class="form-label">City</label>
                            <input type="text" class="form-control" id="city" placeholder="" required="">
                            <div class="invalid-feedback">
                              City required.
                            </div>
                          </div>
              
                          <div class="col-md-3">
                            <label for="zip" class="form-label">Zip</label>
                            <input type="text" class="form-control" id="zip" placeholder="12345" required="">
                            <div class="invalid-feedback">
                              Zip code required.
                            </div>
                          </div>
                          <div class="col-md-3">
                            <label for="studio" class="form-label">Studio Name</label>
                            <input type="text" class="form-control" id="studioName" placeholder="GOOD Records" required="">
                            <div class="invalid-feedback">
                              Studio name required.
                            </div>
                          </div>
                        </div>
              
                        <hr class="my-4">
              
                        <h4 class="mb-3">Payment</h4>
              
                        <div class="my-3">
                          <div class="form-check">
                            <input id="credit" name="paymentMethod" type="radio" class="form-check-input" checked="" required="">
                            <label class="form-check-label" for="credit">Credit card</label>
                          </div>
                          <div class="form-check">
                            <input id="debit" name="paymentMethod" type="radio" class="form-check-input" required="">
                            <label class="form-check-label" for="debit">Debit card</label>
                          </div>
                          <div class="form-check">
                            <input id="paypal" name="paymentMethod" type="radio" class="form-check-input" required="">
                            <label class="form-check-label" for="paypal">PayPal</label>
                          </div>
                        </div>
              
                        <div class="row gy-3">
                          <div class="col-md-6">
                            <label for="cc-name" class="form-label">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 class="col-md-6">
                            <label for="cc-number" class="form-label">Credit card number</label>
                            <input type="text" class="form-control" id="cc-number" placeholder="" required="">
                            <div class="invalid-feedback">
                              Credit card number is required
                            </div>
                          </div>
              
                          <div class="col-md-3">
                            <label for="cc-expiration" class="form-label">Expiration</label>
                            <input type="text" class="form-control" id="cc-expiration" placeholder="" required="">
                            <div class="invalid-feedback">
                              Expiration date required
                            </div>
                          </div>
              
                          <div class="col-md-3">
                            <label for="cc-cvv" class="form-label">CVV</label>
                            <input type="text" class="form-control" id="cc-cvv" placeholder="" required="">
                            <div class="invalid-feedback">
                              Security code required
                            </div>
                          </div>
                        </div>
              
                        <hr class="my-4">
              
                        <button class="w-100 btn btn-primary btn-lg" type="submit" onclick="save()", onclick="submitStu()", window.location.href='editprofile.html'">Update Info</button>
                      </form>
                    </div>
                  </div>
                </main>
              
                <footer class="my-5 pt-5 text-muted text-center text-small">
                  <p class="mb-1">© 2022 StudioPick.</p>
                  <ul class="list-inline">
                    <li class="list-inline-item"><a href="#">Privacy</a></li>
                    <li class="list-inline-item"><a href="#">Terms</a></li>
                    <li class="list-inline-item"><a href="#">Support</a></li>
                  </ul>
                </footer>
              </div>
        </form>
    <!-- The core Firebase JS SDK is always required and must be listed first -->
    <script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-app.js"></script>

    <!-- TODO: Add SDKs for Firebase products that you want to use
        https://firebase.google.com/docs/web/setup#available-libraries -->
    <script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-auth.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-database.js"></script>

    <!---Javascript--->
    <script src="Javascript/editprofile.js"></script>
    <!---Javascript--->
    
    <!----More Bootstrap--->
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
    <!----More Bootstrap--->
</body>
</html>

Javascript Code:

// Initialize Firebase
firebase.initializeApp(firebaseConfig);


//Creating sets in database
firebase.database().ref("/Studiopick/studios").child("users").update({
    purpose : "adding user"
    
});

//Save information
function save(){
    studioName = document.getElementById("studioName").value;
    firebase.database().ref("/Studiopick/studios/users").child(studioName).update({
        email : email,
        phoneNumber : phoneNumber,
        city : city,
        purpose : "adding user"
    
    });

}

Via Active questions tagged javascript - Stack Overflow https://ift.tt/SnzXYF5

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

Confusion between commands.Bot and discord.Client | Which one should I use?

Whenever you look at YouTube tutorials or code from this website there is a real variation. Some developers use client = discord.Client(intents=intents) while the others use bot = commands.Bot(command_prefix="something", intents=intents) . Now I know slightly about the difference but I get errors from different places from my code when I use either of them and its confusing. Especially since there has a few changes over the years in discord.py it is hard to find the real difference. I tried sticking to discord.Client then I found that there are more features in commands.Bot . Then I found errors when using commands.Bot . An example of this is: When I try to use commands.Bot client = commands.Bot(command_prefix=">",intents=intents) async def load(): for filename in os.listdir("./Cogs"): if filename.endswith(".py"): client.load_extension(f"Cogs.{filename[:-3]}") The above doesnt giveany response from my Cogs ...