javascript - How to prepend a specific string to a select option in a HTML form -


i have simple html form dropdown list name of images saving selecting database:

<form name="htmlform" method="post" action="html_form_send.php">     <table width="450px">         <select name="rating">             <option value="image1">image1</option>             <option value="image2">image2</option>             <option value="image3">image3</option>             <option value="image4">image4</option>         </select>         <tr>             <td colspan="2" style="text-align:center">                 <input type="submit" value="submit">             </td>         </tr>     </table> </form> 

what want save whole path of image without showing path user, append static path of selections of user when press submit e.g. prepend: “path/to/my/file” selected image if select image1 save path/to/my/file/image1.png database.

any idea how can this?

you can setting path in value attribute of each <option>. either server side or can in jquery:

$('[name="rating"] > option').each(function() {     this.value = '/path/to/file/' + this.value; }) 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -