I am looking to append a new, (create dynamically) text area in JQuery Mobile on my web page. I have a multiple select box at the top of my page, and depending on which selections I pick I would like to add x number of text areas. How might I start this off?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header" data-position="fixed" data-theme="b">
<h1>Home</h1><!--Header text-->
</div>
<div data-role="content">
<form method="post" data-id="two">
<label for="select-choice-6" class="select">Search by:</label>
<select name="select-choice-6" id="select-choice-6" class="select" multiple="multiple" data-native-menu="false">
<option>Search by:</option>
<option value="id">Student ID</option>
<option value="permit">Permit</option>
<option value="license">License Plate</option>
<option value="first">First Name</option>
<option value="last">Last Name</option>
<option value="lot">Lot Code</option>
</select>
<script>
//.......
for(var j = 0; j < counts; j++)
{
$('form', "#two").append("<textarea name=\"textarea\""+(j+1)+" id=\"textarea+\""+(j+1)+" placeholder=\"");
var str = stuffArray.pop();
alert(str);
switch(str)
{
case "id":
$('form', "#two").append("Student ID");
break;
case "permit":
$('form', "#two").append("Parking Permit");
break;
case "license":
$('form', "#two").append("License Plate");
break;
case "first":
$('form', "#two").append("First Name");
break;
case "last":
$('form', "#two").append("Last Name");
break;
case "lot":
$('form', "#two").append("Lot");
break;
default:
alert("default case");
break;
}
$('form', "#two").append("\"></textarea><br>");
$("#home").trigger("create");
}
//......
</script>
stuffArray is a String array that holds the values of the boxes the user wants. This second bit of code here is simply to append the right tags to make a text area appear but there seems to be a hiccup in the code.