By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,349 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,349 IT Pros & Developers. It's quick & easy.

Need to tab through a form

P: 18
Quick (and hopefully easy) question . . .
Iím trying to figure out where in the following php code to place the tabindex number. What the code does is show the already selected answer that has been saved to a MySql table. I have other fields before and after and would like to be able to tab through them all.
Iíve tried different places but keep getting this error - Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';'
Hope someone can help me out.
Thanks

[PHP]
<?php
// the list in PHP terms (in an array)
$dropDownList = array (
"",
"Yes",
"No",
);

// grab data from database
$result = mysql_query("SELECT `myfield` FROM `MYTABLE` WHERE ID='{$_SESSION['ID']}'");

// put data into an array
$dataArray = mysql_fetch_array($result);

// now output
echo "<select name=\"myfield\">\n";

foreach($dropDownList as $listItem)
{
// output <option> for this item in the list

// if this item matches DB value, then we put in SELECTED.
if ($dataArray[0] == $listItem)
{
echo "<option value=\"{$listItem}\" SELECTED>{$listItem}</option>\n";
}
// otherwise, just output it normally
else
{
echo "<option value=\"{$listItem}\">{$listItem}</option>\n";
}
}

echo "</select>";

?>[/PHP]
Feb 6 '08 #1
Share this Question
Share on Google+
5 Replies


Markus
Expert 5K+
P: 6,050
Can you show the code that gives you the error?
Feb 6 '08 #2

P: 18
I'm putting [HTML]tabindex="5"[/HTML]. This drop down is the 5th field in the tab order.
Feb 7 '08 #3

Markus
Expert 5K+
P: 6,050
I'm putting [HTML]tabindex="5"[/HTML]. This drop down is the 5th field in the tab order.
And you putting that in the select?
Expand|Select|Wrap|Line Numbers
  1. <select name=\"name\" tabindex=\"5\">
  2.  
?
Feb 7 '08 #4

P: 18
I am now!!! :) I forgot about using "\". Thanks so much!
Feb 7 '08 #5

Markus
Expert 5K+
P: 6,050
I am now!!! :) I forgot about using "\". Thanks so much!
No problem, friend.

The silliest mistakes happen to the best of 'em!

Markusn000bz.
Feb 7 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.