0

help me to set value in drop down .I want to fetch two ids 1.$row[0].
2.$row[3] from a view and selected is not set.

<td colspan='2'><b>Select a Publication and Year</b><br>
	
		<select name="publication_name" id="publication_name" onchange="show_year(this.value);">		
		<?php
			$get_publn_name=mysql_query("SELECT anPublicationId,sPublicationName,sPublicationShortName,anYearId,nPublicationYear FROM view_publication_year order by nPublicationYear");
		?>
			<option value=0>-- Select Publication --</option>
		<?php
			while($row=mysql_fetch_row($get_publn_name))
			{
				if(isset($_GET["id"]) and $_GET["id"]==$row[0])
				{
					echo "<option value=".$row[0].",".$row[3]." selected=true>".$row[1]."-".$row[4]."</option>";
				}
				else
					echo "<option value=".$row[0].",".$row[3].">".$row[1]."-".$row[4]."</option>";
			}
		?>
		</select> 
	</td>
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by as.bhanuprakash
0

help me to set value in drop down .I want to fetch two ids 1.$row[0].
2.$row[3] from a view and selected is not set.

<td colspan='2'><b>Select a Publication and Year</b><br>
	
		<select name="publication_name" id="publication_name" onchange="show_year(this.value);">		
		<?php
			$get_publn_name=mysql_query("SELECT anPublicationId,sPublicationName,sPublicationShortName,anYearId,nPublicationYear FROM view_publication_year order by nPublicationYear");
		?>
			<option value=0>-- Select Publication --</option>
		<?php
			while($row=mysql_fetch_row($get_publn_name))
			{
				if(isset($_GET["id"]) and $_GET["id"]==$row[0])
				{
					echo "<option value=".$row[0].",".$row[3]." selected=true>".$row[1]."-".$row[4]."</option>";
				}
				else
					echo "<option value=".$row[0].",".$row[3].">".$row[1]."-".$row[4]."</option>";
			}
		?>
		</select> 
	</td>

I don't think selected=true actually works in all browsers, I think what you want is selected="selected". Also I don't know what will happen with your values since you are including two fields in each separated by commas if you don't include some type of quotation in there. For example if I have <option value=tow,three> who knows what is going to happen when you test across different browsers and platforms.. You really should include these values in quotations as well as selected="selected". quotations may seem minute until you have to look through a large html document and try to determine if your html is being parsed correctly. This is another thing that you can do is view source from a browser and paste it into an html editor and see if it parses correctly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.