Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:43:48+00:00 2026-06-01T18:43:48+00:00

For one reason or other ( I’m not going to go into why here)

  • 0

For one reason or other ( I’m not going to go into why here) I need to use javascript to get the values of 12 hidden input fields and set a variable for each value.

I am not sure what the best approach for this would be. I’d like to be able to get the values and if they are not created i.e. the input fields are not there then id like to generate an error.

Would using a try / catch be good for this or should I simply be using typeof to check the variables have been created?

would putting them in an array as well so i can loop through to check their existance be a good idea?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:43:49+00:00Added an answer on June 1, 2026 at 6:43 pm

    This is the easy way of doing it. try-catch is rather heavy. Also, where would you throw the error to? Instead of unwinding your flow on error, collect your errors into a well structured response. That way if your first one is missing, but the other X are not, then you still get some work done.

    if ( typeof( something ) !== "undefined" ) { doStuff(); }
    

    Otherwise, I’d need more information to help you with your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any particular reason to use one over the other? I personally tend
Pretty self explanatory question. Is there any reason to use one or the other?
Why is it not advisable to use JavaScript in JSP? One rationale that I
Is there any reason to favor one of these approaches over the other when
I have some classes that, for one reason or another, cannot be or need
Besides transporting captcha imgs & copy-righted imgs, is there any other reason why one
I have implemented several of UISegmentedControl objects before but for one or other reason
EDIT: after reading all the input from the other users, i decided, to use
1) One reason to use encapsulation is that by hidding internal implementation details we
Which one is recommended considering readability, memory usage, other reasons? 1. String strSomething1 =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.