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

  • Home
  • SEARCH
  • 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 8001613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:12+00:00 2026-06-04T16:08:12+00:00

i cant understand why this simple function doesnt work in the way i want

  • 0

i cant understand why this simple function doesnt work in the way i want it to work 🙂

c = document.form.product_catid.selectedIndex;
if (document.form.product_name.value == "" && document.form.product_catid[c].value == "")
{
    alert ("Please, define at least product name or product category !");
    return false;
}
else if (!(document.form.product_name.value == "")) 
{
    return true;
}
else if (!(document.form.product_catid[c].value == "")) 
{
    return true;
}
else
{ 
    alert ("Please, dont define two of them at the same time!");
    return false; 
}
return true;

all i want is when input with name product_name is filled OR select with name product_catid is selected, the function is returned true, but if none of them or both are defined, i want it to alert two different alerts ) thank you all for the help, i really appreciate it!

  • 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-04T16:08:13+00:00Added an answer on June 4, 2026 at 4:08 pm

    Try debugging your case using Chrome Developer Tools, Firebug, or something similar. My suspicion is that you are trying to compare "" and undefined in the document.form.product_catid[c].value == "" clause (this will be the case when selectedIndex is -1). Try just !document.form.product_catid[c].value instead.

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

Sidebar

Related Questions

I'm not sure why I can't get this to work: A super simple function
I found the code from the net in which i cant understand this line:-
I cant understand what this warning I get on Xcode is about. Searching for
Please help me. I can't understand why this function, that uses texture memory __global__
I'm newbie in Python. I can't understand why this code does not work: reOptions
I've been playing with this and I can't understand why the RegDeleteKey function is
I have a simple html form that submits information with POST function. But when
I can't understand this recursion even though it's a really simple example. When it
I'm just started learning scheme and can't quite understand why this function does not
I cant figure out how to add my simple function to my main program

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.