Hello
I’m using a CRUD generated _form.php in the Yii framework and want to allow the user to add additional dropdown list to the form at the click of a link.Below is my basic html and javascript. Im having proble trying to incorporate it into yii.
<html>
<head>
<script>
var id = 2;
function add_route_field()
{
var obj = document.getElementById("route");
var data = obj.innerHTML;
data += " <br/><select name=‘route[]’ id=‘route"+id+"’><option value=‘joburg’>joburg</option><option value=‘cpt’>cpt</option><option value=‘durban’>durban</option></select><br /><br />";
obj.innerHTML = data;
id++;
}
</script>
</head>
<body>
<form method="post" action="" enctype="multipart/form-data">
<div id="route" align="right">
<select name="route[]" id="route" />
<option value="joburg">joburg</option>
<option value="cpt">cpt</option>
<option value="durban">durban</option>
</select><br />
</div><span onClick="add_route_field()">add routing</span>
</form>
</body>
</html>