when I select 1 and 2, it says "number 2 is not selectednumber 2 is selected
"
All i want is a list, going all the way down:
1 = yes
2 = no
3 = no
4 = yes...
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
}
?>
<form name="form1" method="post" action="find.php">
<p>
<input name="s" type="text" id="s">
string<br>
<input name="f" type="text" id="f">
to find<br>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Originally posted by diamonds you mean strpos() (I did my homework )
Hmm... not sure which would be technically closest to the javascript indexOf()
From the javascript 1.4 manual:
indexOf
Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, or -1 if the value is not found.
From php.net manual
strstr -- Find first occurrence of a string
From php.net manual
strpos -- Find position of first occurrence of a string
So you are just trying to see if they selected an option or not? Try something like this:
PHP Code:
<?PHP
if (isset($_POST["submit"])) {
if (isset($_POST["myselect"])) {
echo "Options were selected";
}
else {
echo "No options were selected";
}
}
?>
<html>
<head>
</head>
<body>
<form action="<?PHP echo $_SERVER["PHP_SELF"]; ?>" method="post">
<!-- The brackets in the select name are important, once we get to the PHP part... It tells the script that it is an array -->
<select name="myselect[]" multiple="multiple">
<option value="1">1
<option value="2">2
<option value="3">3
</select>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
Bookmarks