Click to See Complete Forum and Search --> : textfield problem


zuzupus
09-02-2003, 07:40 AM
hi,

i got problem regarding text field,actually i need text field for admin page so that i can add as many values
for eg. let say user chris geting project every week so that from admin page i can give project name so that when chris logins he will get the project list as drop down

first i thought to make 8 text fields so that when i input some value he will get these values in his form,but then database problem as i can give only one name in text field otherwise database will mess up

so anybody knows some script so that a text field is there and 2 buttons ADD and DELETE so when i enter some value and click on ADD it will add the items and more i click on add it will be shown the list added items and wheni select and click on delete then it will deleted

this will be helpful for me so that when i go to admin page then the added values i can retieve from database and no worry to be data get lost otherwsie when i refresh the data will gone

im totally confused what to do if anybody have any other idea about this it will be appreciable

thanks in advance

xataku_nakusute
09-02-2003, 09:28 PM
i believe i may be able to help you...just specify to me exactly what you want, and also explain in detail what you want the page to do.

[[[terminal_crawler]]]

zuzupus
09-03-2003, 02:53 AM
thanks for ur reply well all i cany just look at the code im psoting here and u will come to know what exactly is it possible to delete the values from select field like option1,2 and 3
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>



<html>
<head>
<title>Select Box</title>
<script language="JavaScript">
<!--

function updateList(theChoice) {
var theList = document.theForm.listBox;
var theLength = document.theForm.listBox.options.length;
var theText = document.theForm.theText.value;
var theValue = document.theForm.theText.value;
var flag = 0;

if(theText != "") {
if(theChoice == "add") {
for(var i = 0; i < theLength; i++) {
if(theText.match(theList.options[i].text)) {
alert("This Option Already Exists");
flag++;
break;
}//endIf
}//endFor
if(flag == 0){
theList.options[theLength] = new Option(theText,theValue);
alert(theText + " was added!");
}//endIf
}//endIf

else if(theChoice == "remove") {
for(var i = 0; i < theLength; i++) {
if(theText.match(theList.options[i].text)) {
theList.options[i] = null;
break;
}//endIf
else {
flag++;
}//endElse
}//endFor
if(flag == theLength) {
alert("This Option Does Not Exist");
}//endIf
else {
alert(theText + " was removed!");
}//endElse
}//endElseIf
}//endIf

else {
alert("Please Enter A Name For The Option!");
}//endElse
}//endFunction

//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="theForm">
<input type="text" name="theText"> <b>Enter Option Name</b>
<br>
<br>
<select name="listBox">
<option value="">Option List</option>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</select>
<br>
<br>
<input type="button" onClick="updateList('add')" value="Add Item">
<br>
<input type="button" onClick="updateList('remove')" value="Remove Item">
</form>
</body>
</html>


thanks