Forums
This topic is locked
DDD menu, got it work, how to show static text?
Posted 14 Mar 2003 20:15:18
1
has voted
14 Mar 2003 20:15:18 Manou Manou posted:
H;
eventually the Dynamic drop down menu on my search page works.
I have made a search page using two drop down and a submit button, that
populate some data from db, using DWMX and php/mysql,
it works fine, there are two things I like to find out and I need some help
if anyone can help, i am greatful for that.
first Q: how can I have a text stays on top of the drop down menu as
default and show up when page loads,( i want to do this for two of the drop down
have),
text like: <- - please select one - - >
if I put the above text inside the same table in database, I might have some
problem , becasue I want to show the data of db as DESC and then this text
will not show up that way.
on design mode, when you click on "dynamic" button while menu is selected,
there is an option of "staic option" I have inserted the above text and put
0 for value, when loading the search page in IE, it will be on dorp down
menu and it is on top as well, but it does not show up on default, dropdown
shows other item form the db,
Second Q: when viewer does not select anything from the drop down, and click
on submit button, i want an error text comes on the page ( not pop up)that says the
viewer should select something, or somethng like that.
for now if you click on submit button, the detail page opens up but of course, shows nothing .
appreciate any help;
Thanks.
Replies
Replied 15 Mar 2003 00:58:21
15 Mar 2003 00:58:21 Phil Shevlin replied:
Type "selected" next to the static choice
<pre id=code><font face=courier size=2 id=code>
<select name="select">
<option value="0" selected>Please Choose</option>
<%
While (NOT rs.EOF)
%>
<option value="<%=(rs.Fields.Item("YourField"
.Value)%>"><%=(rs.Fields.Item("YourField"
.Value)%></option>
<%
rs.MoveNext()
Wend
If (rs.CursorType > 0) Then
rs.MoveFirst
Else
rs.Requery
End If
%>
</select>
</font id=code></pre id=code>
**** sorry just noticed you are PHP, but you should get the idea. Also search form validation for #2
Edited by - wdglide on 15 Mar 2003 00:59:45
Edited by - wdglide on 15 Mar 2003 01:04:52
<pre id=code><font face=courier size=2 id=code>
<select name="select">
<option value="0" selected>Please Choose</option>
<%
While (NOT rs.EOF)
%>
<option value="<%=(rs.Fields.Item("YourField"


<%
rs.MoveNext()
Wend
If (rs.CursorType > 0) Then
rs.MoveFirst
Else
rs.Requery
End If
%>
</select>
</font id=code></pre id=code>
**** sorry just noticed you are PHP, but you should get the idea. Also search form validation for #2
Edited by - wdglide on 15 Mar 2003 00:59:45
Edited by - wdglide on 15 Mar 2003 01:04:52
Replied 15 Mar 2003 03:16:41
15 Mar 2003 03:16:41 Manou Manou replied:
thank you for the reply;
I have already used "selected" inside the option value command,
the text will be in drop down menu but not show up when page opens up.
it will be anther choice of drop down menu.
Thanks
I have already used "selected" inside the option value command,
the text will be in drop down menu but not show up when page opens up.
it will be anther choice of drop down menu.
Thanks
Replied 15 Mar 2003 03:29:53
15 Mar 2003 03:29:53 Phil Shevlin replied:
I'd have to see the code...
Replied 15 Mar 2003 03:41:30
15 Mar 2003 03:41:30 Manou Manou replied:
Thank you for the reply;
here is the code for the form:
<form action="yellowpage_master.php" method="post" name="searchForm" id="searchForm">
<select name="Menu1" id="Menu1">
<option value="0" <?php if (!(strcmp(0, $row_Rs1['cat_id']))) {echo "SELECTED";} ?>>---Select
Category Here---</option>
<?php
do {
?>
<option value="<?php echo $row_Rs1['cat_id']?>"<?php if (!(strcmp($row_Rs1['cat_id'], $row_Rs1['cat_id']))) {echo "SELECTED";} ?>><?php echo $row_Rs1['cat_name']?></option>
<?php
} while ($row_Rs1 = mysql_fetch_assoc($Rs1));
$rows = mysql_num_rows($Rs1);
if($rows > 0) {
mysql_data_seek($Rs1, 0);
$row_Rs1 = mysql_fetch_assoc($Rs1);
}
?>
</select>
<select name="Menu2" id="Menu2">
<option value=" " <?php if (!(strcmp(" ", $row_Rs2['company_name']))) {echo "SELECTED";} ?>><---Select
Name---></option>
<?php
do {
?>
<option value="<?php echo $row_Rs2['company_name']?>"<?php if (!(strcmp($row_Rs2['company_name'], $row_Rs2['company_name']))) {echo "SELECTED";} ?>><?php echo $row_Rs2['company_name']?></option>
<?php
} while ($row_Rs2 = mysql_fetch_assoc($Rs2));
$rows = mysql_num_rows($Rs2);
if($rows > 0) {
mysql_data_seek($Rs2, 0);
$row_Rs2 = mysql_fetch_assoc($Rs2);
}
?>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
here is the code for the form:
<form action="yellowpage_master.php" method="post" name="searchForm" id="searchForm">
<select name="Menu1" id="Menu1">
<option value="0" <?php if (!(strcmp(0, $row_Rs1['cat_id']))) {echo "SELECTED";} ?>>---Select
Category Here---</option>
<?php
do {
?>
<option value="<?php echo $row_Rs1['cat_id']?>"<?php if (!(strcmp($row_Rs1['cat_id'], $row_Rs1['cat_id']))) {echo "SELECTED";} ?>><?php echo $row_Rs1['cat_name']?></option>
<?php
} while ($row_Rs1 = mysql_fetch_assoc($Rs1));
$rows = mysql_num_rows($Rs1);
if($rows > 0) {
mysql_data_seek($Rs1, 0);
$row_Rs1 = mysql_fetch_assoc($Rs1);
}
?>
</select>
<select name="Menu2" id="Menu2">
<option value=" " <?php if (!(strcmp(" ", $row_Rs2['company_name']))) {echo "SELECTED";} ?>><---Select
Name---></option>
<?php
do {
?>
<option value="<?php echo $row_Rs2['company_name']?>"<?php if (!(strcmp($row_Rs2['company_name'], $row_Rs2['company_name']))) {echo "SELECTED";} ?>><?php echo $row_Rs2['company_name']?></option>
<?php
} while ($row_Rs2 = mysql_fetch_assoc($Rs2));
$rows = mysql_num_rows($Rs2);
if($rows > 0) {
mysql_data_seek($Rs2, 0);
$row_Rs2 = mysql_fetch_assoc($Rs2);
}
?>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
Replied 15 Mar 2003 13:46:27
15 Mar 2003 13:46:27 Phil Shevlin replied:
I've never PHP'd, but it looks like you have "selected" on each menu item.
try:
<pre id=code><font face=courier size=2 id=code>
<option value="0" selected>---Select Category Here---</option>
</font id=code></pre id=code>
Edited by - wdglide on 15 Mar 2003 13:46:48
try:
<pre id=code><font face=courier size=2 id=code>
<option value="0" selected>---Select Category Here---</option>
</font id=code></pre id=code>
Edited by - wdglide on 15 Mar 2003 13:46:48