# How to you call a if function in this scernio?

**URL:** <https://boards.straightdope.com/t/how-to-you-call-a-if-function-in-this-scernio/756828>\
**Category:** Factual Questions\
**Created:** [June 8, 2016, 2:13pm UTC](https://boards.straightdope.com/t/how-to-you-call-a-if-function-in-this-scernio/756828 "2016-06-08T14:13:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Galatus](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Galatus](https://boards.straightdope.com/u/Galatus)\
**Post date:** [June 8, 2016, 2:13pm UTC](https://boards.straightdope.com/t/how-to-you-call-a-if-function-in-this-scernio/756828/1 "2016-06-08T14:13:20Z")

</div>

I had a peace of code:

\<head\>  
\<meta charset=“utf-8”\>  
\<title\>The Elements Search\</title\>  
\<style type=“text/css”\>

\</style\>  
\</head\>

\<body\>

\<div id=“searchbar-frame”\>  
\<div id=“container-1”\>  
\<span id=“icon”\>\<i class=“fa fa-search”\>\</i\>\</span\>  
\<input type=“search” id=“search” placeholder=“Search Elements…” /\>  
\</div\>  
\</div\>

\<script\>  
if document.getElementById()

\</script\>

\</body\>  
\</html\>

In the script, I was trying to call the text in the search bar into the data pit. I wasn’t going to do it with XML, PHP, or SQL. All I want to know is how do I call the user text in a “if” statement.

---

<div class="post-metadata">

**Author:** ![robert\_columbia](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@robert\_columbia](https://boards.straightdope.com/u/robert_columbia)\
**Post date:** [June 8, 2016, 2:41pm UTC](https://boards.straightdope.com/t/how-to-you-call-a-if-function-in-this-scernio/756828/2 "2016-06-08T14:41:17Z")

</div>

> [@Galatus](#):
>
> …  
> In the script, I was trying to call the text in the search bar into the data pit. I wasn’t going to do it with XML, PHP, or SQL. All I want to know is how do I call the user text in a “if” statement.

Assuming you want to do something with the text on the client side using Javascript, you would do something like this:  
\<script type=“text/javascript”\>  
if (document.getElementById(“search”).value == \<whatever you are looking for\>)  
{  
\<do something\>  
}  
else  
{  
\<do something else\>  
}

\</script\>

Is that what you were thinking about? If not, what are you trying to accomplish?
