Jump to content

drop down list from array not entering value correctly


bradkenyon

Recommended Posts

$imgurl = '<img src="/images/icons/img.jpg">';

doctypes = 	array(array("label"=>"(select type)","value"=>""),
                array("label"=>"A4","value"=>"$imgurl"));

 

i am trying to output the drop down w/ select type, and A4, but A4 has the value of <img src="/images/icons/img.jpg">, but it stores that value in the db as <img src=

 

also, in the drop down, it lists A4, and adds a bit of the html into the drop down field, as you'll see in the image.

 

this is the html of it in the source code:

 

<select name='D_doctype' size='1' /><option value="">(select type)</option>
<option value="<img src="/images/icons/img.jpg">">A4</option>
</select>

 

does anyone know why it only stores <img src= in the db table, i put addslashes around it when its inserted into the database, as well as why the html source code is being displayed funny in the drop down, but looks fine in the source code.

 

Because once it reaches that second quote, it thinks the value attribute is done. You need to encode the value getting put there like this:

 

<option value="<?php echo htmlspecialchars($imgurl); ?>">A4</option>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.