PDA

View Full Version : Script Help (many-2-many)



jackavin
09-15-2007, 08:50 AM
if i have

customer
-cid
-name
-lasname

contact
-cid
-telephone

and i want to add telephone like 10 number how can i write the java for add textfield for add number and how can i put on database

thank

Twey
09-15-2007, 09:59 AM
Firstly, that's a one-to-many relationship: there's no way for one telephone number to belong to multiple customers. Secondly, what exactly are you talking about? You've posted this in the Javascript forum, then you're talking about Java, then you want to add a textbox? Do you have some form of Java serverside?

jackavin
09-15-2007, 11:30 AM
<div id="input">
<input type="text" name="telephone1">
</div>
<input type="button" value="เพิ่ม" onclick="add()">
<script>
var counter=1;
function add(){
counter+=1;
document.getElementById("input").innerHTML+="<br><input type='text' name='telephone"+counter+"'>";
}
</script>

something like this i mean i customer can have more than 1 phone number but i dont want to fix the number for each customer

Twey
09-15-2007, 06:03 PM
Ah:
<script type="text/javascript">
function addTelephoneInput() {
var inp = document.createElement("input");
inp.type = "text";
inp.name = "telephone"; // If using PHP, this has to be "telephone[]" due to PHP's limited capabilities.
document.getElementById("input").appendChild(inp);
}
</script>