PHP + Javascript + Checking to see empty values?

  • Thread starter Thread starter evachick156
  • Start date Start date
E

evachick156

Guest
Here is my HTML:
if(!($rows['method'] === "undefined"))
{
echo ("<select class=\"train\" name=\"actualSolution\" id='" . $rows['id'] . "_actual'>");
echo("<option disabled value='" . $rows['id'] . "'>" . $rows['method'] . "</option>");
?>
</select>
<?
}
else
{
echo ("<select class=\"train\" name=\"actualSolution\" id='" . $rows['id'] . "_actual'>");
echo("<option></option>");
?>
</select>
<?
}
?>

My goal is when it hits the ELSE in my if statement i want to check that in my javascript for example:
if(selectActual.options[0] == "")
{
select.options[0] = new Option(outcome, x);
select.options[1] = new Option(b1, x);
select.options[2] = new Option(b2, x);
select.options[3] = new Option(b3, x);
select.options[4] = new Option(b4, x);
select.options[5] = new Option(b5, x);
select.options[6] = new Option(b6, x);
select.options[7] = new Option(b7, x);
select.options[8] = new Option(b8, x);
select.options[9] = new Option(b9, x);
}

If I do hit the else than I want to fill with the above code. But it doesnt hit it. It must be my if statement but how do i check to see if there isnt no "option"?
Ok....so where I have my if statement....I will end up going to the else which has:
<option></option>

In my javascript I want to make sure that I have hit my else by checking to see if its empty (" ") if it is, than i want to fill it with stuff.
However, if i hit the if and dont go to the else, than i dont want to hit that if statement in my javascript.
 
I've tried re-reading what you've written three times now and I can't understand what you're asking.

It would help if you're more specific about what you're asking. Maybe you could give the exact line you have a question about?

It's better to ask these kinds of questions in forums since it's easier for discussions to go back and forth between people.

In your "if" statement, where is $rows coming from? MySQL? Seeing the rest of the code would be useful.

When you say: "My goal is when it hits the ELSE in my if statement i want to check that in my javascript for example" It's very unclear what you want the code below that has to do with the PHP.
 
Back
Top