PDA

View Full Version : drop down box...displaying the default value?


boyzdynasty
04-28-2003, 07:09 PM
ok...i want to have a drop down box but...how do I set the default value that should be displayed?

The first element is the default but I want to change it.

anyone know?

freddycodes
04-28-2003, 07:18 PM
I do, but I am wondering what steps you have taken to try and figure it out. Have you looked in the reference panel under methods for the combo box? Look there and start with setSelectedIndex()

CyanBlue
04-28-2003, 07:21 PM
Huh??? What do you mean???

Are you talking about the ComboBox???
And What default value???
The first items says 'Select', and the ones after that goes like 'Item 1', 'Item 2', 'Item 3', and so on???
If that is the case, just chekc if the selected index is greater than 1 to execute what you want to try???

Let me know and feed my brain... ;)

CyanBlue
04-28-2003, 07:23 PM
Now, I see freddycodes's reply and am all confused...

Is this thread belongs to some other thread??? Or is it just standalone question, boyzdynasty??? ;)

freddycodes
04-28-2003, 07:27 PM
He is just asking how one can set the item that is showing at the top after the thing has been loaded with data, I believe.

boyzdynasty
04-28-2003, 08:40 PM
no...this doesn't pretain to any other threads.

ok...is there a search functionality for it?

Here is what I am trying to do...

I have a menu w/ the drop down...for the TO: field
which contains all the empolyee emails... but the label has the value of employee's name and the data value is the e-mail address...

*Note: 2-Menus (Send, Read)

(In the Read Menu)
When a user hit the reply button...it will go to the Send Menu. Whom ever sent the email there name will be shown in the TO: field

the TO: field is where the drop down box is located.

ah...the only thing I can think of is do a loop and check all the values of the index in the box....dunno if there is some search method in flash already.

At the moment...it is not working but I'll play around w/ it some more.

I hope you guys see what I am trying to do...

boyzdynasty
04-28-2003, 08:44 PM
hmm....actually, the question is part of the school project....so I guess it does revolve around the other post.

BTW: FreddyCodes, do you know anything about php templates?

freddycodes
04-28-2003, 08:48 PM
BTW: FreddyCodes, do you know anything about php templates?

What about them? I know a little about a lot, but not a lot about anything.



As for your drop down problem, so when somone hits reply, you want to search for the existence of their email address in the To drop down list and set it to the top?

boyzdynasty
04-28-2003, 09:01 PM
Originally posted by freddycodes
As for your drop down problem, so when somone hits reply, you want to search for the existence of their email address in the To drop down list and set it to the top? Correct. I was messing w/ it yesterday and I was getting undefine (using trace). When i get home, I'll mess with it some more.

About templates...I'm not sure on how to go about it. I understand the idea of it. Read some stuff from here (http://www.phpbuilder.com/columns/babao20020907.php3?page=1)


In another thread, I was talking about printing and stuff... this post (http://www.actionscript.org/forums/showthread.php3?s=&threadid=26962)

I just want to output the results in a proper table format(rows and cols)
Employee name/Id | Monday | Tuesday | Wednesday |...

*under the days of the week I will indicate the work hrs./shifts
(shift1, 2, 3, 4,and 5)

That is what I'm trying to do...I figured use templates is the way to go...

freddycodes
04-28-2003, 09:10 PM
Templates are nice when you are developing large scale applications, where multiple developers will be working on them, and you have many pieces to your app. So your presentation layer is merely a set of templates, and your business objects supply data to your presentation layer, which populate the templates.

For your scenario here, it might be easier to just use PHP to repeat a chunk of html as many times as you need it. Example


<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Name</td>
<td>Email</td>
<td>Mon</td>
<td>Tues</td>
<td>Wed</td>
<td>Thurs</td>
<td>Fri</td>
</tr>
<?php
$result = mysql_query("SELECT something from somewhere order by me");
while($row = mysql_fetch_array($result)) {
?>
<tr bgcolor="<?php print (++$i%2==0) ? '#CCCCCC' : '#FFFFFF'; ?>">
<td><?php print $row['name']; ?></td>
<td><?php print $row['email']; ?></td>
<td><?php print $row['mon_hours']; ?></td>
<td><?php print $row['tues_hours']; ?></td>
<td><?php print $row['wed_hours']; ?></td>
<td><?php print $row['thurs_hours']; ?></td>
<td><?php print $row['fri_hours']; ?></td>
</tr>
<?php
}
?>
</table>




That is pretty much a low level inline template, and useful for simple lists and such.

If you really want to get a handle on templates in PHP, I suggest playing with a template system such as Smarty
http://smarty.php.net

But be careful there can be some overhead using these types of systems.

boyzdynasty
04-28-2003, 09:21 PM
the example you posted...is that in a *html file of *php file?
It looks like php is embedded in a html file....

boyzdynasty
04-28-2003, 09:42 PM
FreddyCodes...

I change your code to this...I filled in the select stuff...anyways...the result doestn't look to good

<?php

include ('common.php');

// Have this function that connects to database in the above include file...
// Works fine...
$link = dbConnect();

print '<table cellpadding="0" cellspacing="0" border="0">';
print '<tr>';
print '<td>First Name</td><td>Last Name</td>';
print '</tr>';

$result = mysql_query("SELECT firstName, lastName from $table");

while($row = mysql_fetch_array($result)) {

print '<tr bgcolor="' . (++$i%2==0) ? '#CCCCCC' : '#FFFFFF' . '">';

print '<td>' . $row['firstName'] .'</td>';
print '<td>' . $row['lastName'] . '</td>';

print '</tr>';

}

print '</table>';

mysql_close($link);

?>


The result of the script can be viewed HERE (http://eskills.cis.temple.edu/cis339/final/test.php)

freddycodes
04-28-2003, 09:48 PM
Now why did you have to go and screw it all up like that, you are using wasted memory having PHP write all that html code out. What if you just did this


<?php
include ('common.php');

// Have this function that connects to database in the above include file...
// Works fine...
$link = dbConnect();

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>First Name</td>
<td>Last Name</td>
</tr>
<?php
$result = mysql_query("SELECT firstName, lastName from $table");

while($row = mysql_fetch_array($result)) {
?>
<tr bgcolor="<?php print (++$i%2==0) ? '#CCCCCC' : '#FFFFFF'; ?>">
<td><?php print $row['firstName']; ?></td>
<td><?php print $row['lastName']; ?></td>
</tr>
<?php
}
?>
</table>


</body>
</html>



BTW it was broken because of the ternary operator line, the one with () ? :

freddycodes
04-28-2003, 09:50 PM
the example you posted...is that in a *html file of *php file?
It looks like php is embedded in a html file....


I think you might be confused as to what exactly PHP is. It is not meant to write html code out, its meant to be embedded into your html code as a server-side interpreted scripting language.

Yes you can write classes and functions and whatever you want in PHP. But it was initially designed to be nothing more than a scripting language. PHP5 should change alot of that.

boyzdynasty
04-28-2003, 11:55 PM
I know.
I just wanted to see if it worked the way i had set up.

I understand what you are saying.
But I still need a lot of work.

I was reading some notes on PHP5.... some things I don't even understand but I guess the best way is to play w/ it and see how the code actually works.

I really like PHP...i guess b/c that is the only server side script I am learning. ;)