|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
syntax question
$question_01 = "selected";
this works fine... PHP <? print "<option value=\"01\" $question_01 > What is your father's middle name?";?> this does not... HTML <option value="01" <? $question_01?> > What is your father's middle name? is there a way in a option statement to include this variable inside the html brackets without having to use php to parse the entire line? |
|
#2
|
||||
|
||||
|
It might be considered sloppy coding...
But i think this is what you're after: <option value="01" <?=$question_01;?>> What is your father's middle name?</option> |
|
#3
|
|||
|
|||
|
ty, thats the syntax i needed
![]() |
|
#4
|
||||
|
||||
|
no problem...
Just to clarify my "sloppy coding" comment... The suggested way to set to set an option as selected is selected="selected" this may seem odd, but that's how the W3C set their standards... its based on XML, attributes should be name/value pairs... thus, I'd recommend $question_01='selected="selected"'; Also, I question your variable $question_01... but I guess its being set by a database value, or maybe a $_POST or $_GET value... i'm sure you have that logic figured out =) Glad to hear its working. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > syntax question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|