Jump to content

ask user to enter some data , check for a condition and display result


Karneet

Recommended Posts

Hello Everyone,

I am new JavaScript and would like to help my friend with her website. She wants the user to enter the data such as age and marital status. Check for a condition if the age is less than 25 and marital status is single she wants the user to see a specific message. In the same way if the age is more than 25 and status is single some other information. Can anyone please help me with it. Any help would be gratefully accepted.

 

Link to comment
Share on other sites

what do you have so far? which part are you stuck with? Provide code and specifics and then we will be able to help you.

Link to comment
Share on other sites

what do you have so far? which part are you stuck with? Provide code and specifics and then we will be able to help you.

Hello Sir thank you for taking time and replying to me. the code i have so far is as follows: <html>

<head>
<script type="text/javascript">
function start(age(), abc())
{
abc();
age();
}
</script>
</head>
<body>
if(age<25 && abc=yes)
{
alert("you can apply");
}
else if( age>25 && abc =yes)
{
alert("you can apply");
}
else if(age<25 && abc=no)
{
alert("no");
}
else
{
alert("no");
}
</body>
</html>
can you please tell me where i am going wrong. I would appreciate it
Link to comment
Share on other sites

Have you gone through the tutorials on javascript yet? I would highly recommend you do.

 

You're going to need at minimum the knowledge on

* how to include Javascript correctly on your page

* how to define variables

* how to correctly use operators

* how to interact with the DOM; using something like document.getElementById,

* how to write and call functions

 

also you would need to use a browsers developer tools to check for errors, cause there would be many of them generated from this script.

 

Once you have read through the tutorials, you need to think out your approach.

 

* How does the user provide input? You have absolutely no HTML on your page within the body tags. You're going to at minimum need a couple input elements.

* How do you get the user input?

* Define the requirements of your function and the comparison logic

 

One step at a time, but first you need to study to understand the basics.

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...