R

자바스크립 고수님 들..ㅠ.ㅠ 도와주세요..

이런저런 이유로 요 몇일 스킨을 제작중인데요..ㅠ.ㅠ

스크립이...ㅜ.ㅜ 말을 안들어가...

innerHTML 로 테이블과 텍스트 박스 및 셀렉트 박스를 생성후
컨트롤 하려 하는데요.
이상하게 primary_key() 에서
var optionValue = document.create_table['create_field_name['+i+']'].value;
요넘을 못불러오네요..ㅠ.ㅠ

datetype()에서는
document.create_table["create_date_len["+j+"]"].value
요넘은 아주 잘 불러지고 있는데요..ㅠ.ㅠ
그런데 요넘두 primary_key() 요기로 가서 부르면 안오더라구요..ㅜ.ㅠ
뭘 잘못한건지 도저히 알수가없어서 자문을 구합니다..

아래는 소스 입니다.





<style>
.field_title {
height:30px;
color: #FFFFFF;
}
.field_text {
color: #333333;
}
</style>
<script>
var i = 0;
function add_field()
{
oRow0 = document.createElement('tr');
oRow1 = document.createElement('tr');
oCel0 = document.createElement('td');
oCel1 = document.createElement('td');
oCel2 = document.createElement('td');
oCel3 = document.createElement('td');
oCel4 = document.createElement('td');
oCel5 = document.createElement('td');

oRow0.style.textAlign='center';
oRow0.style.height='32';
oRow1.style.textAlign='center';
oCel5.height='1';
oCel5.bgColor='#e3dcd2';
oCel5.colSpan='5';

oCel0.className='cel0';
oCel1.className='cel1';
oCel2.className='cel2';
oCel3.className='cel3';
oCel4.className='cel4';
oCel5.className='cel5';

oRow1.appendChild(oCel5);
oRow0.appendChild(oCel0);
oRow0.appendChild(oCel1);
oRow0.appendChild(oCel2);
oRow0.appendChild(oCel3);
oRow0.appendChild(oCel4);
oRow0.appendChild(oRow1);

oCel0.innerHTML="#"+i;
oCel1.innerHTML="<input type='text' name='create_field_name["+i+"]' style='width:100%; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;' itemname='테이블명' required>";
oCel2.innerHTML="<select name='create_date_type["+i+"]' onChange='datetype(this.value, "+i+")' style='width:100%; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;' itemname='데이터 타입' required><option selected='selected'>DateType</option><option value='int'>INT</option><option value='char'>CHAR</option><option value='varchar'>VARCHAR</option><option value='text'>TEXT</option></select>";
oCel3.innerHTML="<input type='text' name='create_date_len["+i+"]' style='width:100%; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;' itemname='문자길이'>";
oCel4.innerHTML="<select name='create_not_null["+i+"]' style='width:100%; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;' itemname='NULL'><option value='n'>NOT NULL</option><option value='y' selected='selected'>NULL</option></select>";
oCel5.innerHTML="";

document.getElementById('table_field').children(0).appendChild(oRow0);
document.create_table.field_count.value=i;
i++;
}


function del_field()
{
var tbody = document.getElementById('table_field');

if(tbody.rows.length > 4) {
tbody.deleteRow(tbody.rows.length-2);
i--;
document.create_table.field_count.value=i;
}else{
alert("최소 1개이상의 Field 가 있어야 합니다.");
}
}

function primary_key()
{
var p_count = document.create_table.field_count.value;
var key_count = document.create_table.create_primary_key.length;
for(i=0; i==p_count; i++)
{
var optionValue = document.create_table['create_field_name['+i+']'].value;
if(!optionValue)
{
alert("#"+i+"번 Field Name 이 존재 하지 않습니다.");
}else{
for (d=0; d < key_count; d++){
document.create_table.create_primary_key.options.remove(0);
}
var newItem = new Option;
newItem.text = optionValue;
newItem.value = optionValue;
document.create_table.create_primary_key.options[document.create_table.create_primary_key.length]=newItem;
}
}
}

function datetype(type, j_no)
{
var j = j_no;
var type = type;
var date_type_len = "int-4^char-8^varchar-80^text-65535";
var date_type = date_type_len.split("^");
for(f=0; f<date_type.length; f++)
{
var date_len = date_type[f].split("-");
if(date_len[0] == type)
{
document.create_table["create_date_len["+j+"]"].value = date_len[1];
}
}


}

</script>
<body onLoad="add_field()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class='ht'>
<td align=left><?=subtitle("Db 생성")?></td>
</tr>
<tr>
<td class=line1>
</td>
</tr>
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<form name="create_table" method="post" action="<?=$g4['admin_path']?>/create_table_update.php">
<input name="field_count" type="hidden" value=0><input name="field_namelist" type="hidden" value="Primary Key 를 선택해주세요">
<tr>
<td>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="center">Table Name</td>
<td>
<input type="text" name="create_table_name" style="width:300px; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;" itemname="Table Name" required>
</td>
</tr>
</table>

</td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="1" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">Date Field 추가</td>
</tr>
<tr>
<td height="5" align="center"></td>
</tr>
<tr>
<td align="center"><span onClick="add_field();" style="cursor:pointer;">+</span>  <span onClick="del_field();" style="cursor:pointer;">-</span></td>
</tr>
</table></td>
<td>

<table border="0" id="table_field" cellspacing="1" cellpadding="0">
<tr>
<td width="50" align="center" bgcolor="#CBB08D" class="field_title">NO</td>
<td width="200" align="center" bgcolor="#CBB08D" class="field_title">Field Name</td>
<td width="180" align="center" bgcolor="#CBB08D" class="field_title">Date Type</td>
<td width="100" align="center" bgcolor="#CBB08D" class="field_title">Date length</td>
<td width="120" align="center" bgcolor="#CBB08D" class="field_title">NULL</td>
</tr>


</table>


</td>
</tr>
</table>



</td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="1" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="center">PRIMARY KEY</td>
<td>
<select name="create_primary_key" onFocus="primary_key()" style="width:160px; background-color:#f6f6f6; border:1px solid #d8d8d5; height:21px;" itemname="PRIMARY KEY" required>
<option selected>Primary Key</option>
</select>
</td>
</tr>
</table>

</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class=line1>
</td>
</tr>
<tr>
<td align="right"><input type="submit" name="button" id="button" value="Table 생성" /></td>
</tr>
<tr>
<td> </td>
</tr>
</form>
</table>


</td>
</tr>
</table>
|

댓글 2개

for문이 잘못된것 같은데요..

for(i=0; i<=p_count; i++)

이처럼 작성해야 할것 같습니다..
그럼 optionValue는 잡아 내는데..
오타이신것 같네요.. ㅎㅎ
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

태그 필터 (최대 3개) 전체 개발자 소스 기타 mysql 팁자료실 javascript php linux flash 정규표현식 jquery node.js mobile 웹서버 os 프로그램 강좌 썸네일 이미지관련 도로명주소 그누보드5 기획자 견적서 계약서 기획서 마케팅 제안서 seo 통계 서식 통계자료 퍼블리셔 html css 반응형 웹접근성 퍼블리싱 표준화 반응형웹 홈페이지기초 부트스트랩 angularjs 포럼 스크린리더 센스리더 개발자톡 개발자팁 퍼블리셔톡 퍼블리셔팁 기획자톡 기획자팁 프로그램강좌 퍼블리싱강좌
+
제목 글쓴이 날짜 조회
17년 전 조회 1,503
17년 전 조회 1,321
17년 전 조회 2,597
17년 전 조회 1,349
17년 전 조회 1,609
17년 전 조회 1,491
17년 전 조회 1,798
17년 전 조회 1,812
17년 전 조회 1,829
17년 전 조회 1,891
17년 전 조회 1,554
17년 전 조회 1,633
17년 전 조회 1,536
17년 전 조회 1,883
17년 전 조회 1,792
17년 전 조회 1,592
17년 전 조회 1,775
17년 전 조회 1,429
17년 전 조회 1,668
17년 전 조회 1,983
17년 전 조회 2,814
17년 전 조회 2,025
17년 전 조회 1,432
17년 전 조회 1,983
17년 전 조회 2,444
17년 전 조회 1,596
17년 전 조회 2,358
17년 전 조회 1,785
17년 전 조회 1,494
17년 전 조회 1,347
17년 전 조회 2,015
17년 전 조회 2,916
17년 전 조회 2,535
17년 전 조회 1,548
17년 전 조회 2,902
17년 전 조회 2,435
17년 전 조회 2,787
17년 전 조회 2,800
17년 전 조회 2,573
17년 전 조회 2,393
17년 전 조회 1,747
17년 전 조회 2,485
17년 전 조회 3,979
17년 전 조회 1,851
17년 전 조회 3,948
17년 전 조회 1,870
17년 전 조회 1,765
17년 전 조회 2,100
17년 전 조회 2,499
17년 전 조회 1,464
17년 전 조회 1,801
17년 전 조회 2,369
17년 전 조회 1,842
17년 전 조회 1,779
17년 전 조회 1,574
17년 전 조회 1,416
17년 전 조회 1,374
17년 전 조회 1,182
17년 전 조회 1,177
17년 전 조회 1,199
17년 전 조회 1,211
17년 전 조회 1,626
17년 전 조회 1,708
17년 전 조회 1,849
17년 전 조회 2,980
17년 전 조회 2,124
17년 전 조회 1,795
17년 전 조회 2,133
17년 전 조회 1,848
17년 전 조회 3,380
17년 전 조회 1,561
17년 전 조회 1,681
17년 전 조회 1,399
17년 전 조회 2,214
17년 전 조회 3,155
17년 전 조회 2,297
17년 전 조회 1,755
17년 전 조회 3,012
17년 전 조회 4,460
17년 전 조회 1,775
17년 전 조회 3,268
17년 전 조회 1,595
17년 전 조회 3,505
17년 전 조회 5,864
17년 전 조회 1,444
17년 전 조회 2,187
17년 전 조회 1,809
17년 전 조회 1,560
17년 전 조회 2,440
17년 전 조회 2,651
17년 전 조회 1,619
18년 전 조회 2,708
18년 전 조회 3,193
18년 전 조회 1,549
18년 전 조회 1,973
18년 전 조회 3,872
18년 전 조회 4,504
18년 전 조회 1,894
18년 전 조회 1,759
18년 전 조회 2,697