Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Need help with to <script> codes on the same page.

BRCO

Coder
JavaScript:
** FIRST**   <script>
export default {
  name: 'UserSetting',
  data: function(){
    return {
      user_email: '',
      user_new_password: '',
      user_confirm_password: '',
      user_existing_password: '',
    }
  },
  mounted: function () {
    this.loadUserDetails();
  },
  methods: {
    loadUserDetails: function() {
      this.$http.get('users/' + localStorage.getItem('user') + '/user_details')
        .then(response => {
          if(response.data != null) {
            this.user_email = response.data.email
          }
        })
        .catch(error => {
         
          this.$parent.toast(error);
        });
    },
    saveUserDetail: function(){
      if (this.user_existing_password == ''){
        alert('To update settings, you need to enter current password.')
      }
      else{
        this.$http.put('users/' + localStorage.getItem('user') + '/user_details',
        {
          user_email: this.user_email,
          user_new_password: this.user_new_password,
          user_confirm_password: this.user_confirm_password,
          user_existing_password: this.user_existing_password

        })
        .then(response => {
          this.$parent.toast("Settings have been updated successfully");
          location.reload();
        })
        .catch(error => {
          this.$parent.toast(error);
        });
      }
     
    }
  }
}
</script>
**SECOND** <script>
import Profile from './Profile.vue'
import Plan from './Plan.vue'



export default {
  name: 'Summary',
  props: {
    selectedYear: Number
  },
  components: {
    Profile,
    Plan  
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>


So the first <script> is for email and pass change the <script> underneath it is for the Profile and plan section... However, the first <script> is not working unless I move it under the second <script> but when I do that then the Profile and Plan sections disappear.

Is anyone able to help me out with this?
 
Back
Top Bottom