Jump to content

Problem with a function...!

- - - - -

  • Please log in to reply
4 replies to this topic

#1
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
I have a function in JS but when I call it vepro('contact'); OR vepro('kid') it shows the same result the result is "You want to delete this contact?". So I can never get "You want to delete this kid?" What may be the problem?

function vepro(faqja)

{

	if (faqja = 'contact')

	{

		var ask = confirm("You want to delete this contact?");

	}

	else if (faqja = 'kid')

	{

		var ask = confirm("You want to delete this kid?");

	}

}


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Can you show how you're calling this?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
This codes above gives me the same result the first result as I said in the first post:
<a href="#" onClick="vepro('contact')" title="Fshi" class="icon-2 info-tooltip"></a>

AND

<a href="#" onClick="vepro('kid')" title="Fshi" class="icon-2 info-tooltip"></a>



#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
   function vepro(faqja)
    {
        if (faqja == 'contact')
        {
            var ask = confirm("You want to delete this contact?");
        }
        else if (faqja == 'kid')
        {
            var ask = confirm("You want to delete this kid?");
        }
    }
You have to use == for comparison. = is assignment, and non-null evaluates to true.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
Thanks a lot I though that I tried once with == but who knows what I did wrong then, now it is ok.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users