Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- WebView
- Redirect
- Maven
- MS-SQL
- 자바
- Java
- asp.net
- Web Service
- Apache Lucene
- jsp
- varags
- TextBox
- javascript
- C#
- 안드로이드
- 자바스크립트
- decompiler
- Bootstrap
- MSsql
- Android
- 컬럼명
- 이클립스
- scrollView
- 웹뷰
- STS
- html
- Eclipse
- SpringSource Tool Suite
- 웹 서비스
- MANTIS
Archives
- Today
- Total
bboks.net™
JavaScript 다중 폼(form)이 있는 페이지에서 특정 폼의 요소에 접근하기 본문
접근방법
예를 들어
위와 같이 페이지가 구성되어 있을 때 form2의 writer에 값을 지정할 때는
[참고] Using JavaScript to access form objects when there are multiple forms
documents.forms["폼 이름"].elements["엘레먼트 이름"];
예를 들어
<div id="dialog" style="display: none">
<form name="form1" method="post" action="save.do">
<table>
<tr>
<td>이름</td>
<td><input type="text" name="writer"></td>
</tr>
<tr>
<td>내용</td>
<td><input type="text" name="contents"></td>
</tr>
</table>
</form>
</div>
<div id="modify" style="display: none">
<form name="form2" method="post" action="save.do">
<table>
<tr>
<td colspan="2"><input type="hidden" name="id"></td>
</tr>
<tr>
<td>이름</td>
<td><input type="text" name="writer"></td>
</tr>
<tr>
<td>내용</td>
<td><input type="text" name="contents"></td>
</tr>
</table>
</form>
</div>
<form name="form1" method="post" action="save.do">
<table>
<tr>
<td>이름</td>
<td><input type="text" name="writer"></td>
</tr>
<tr>
<td>내용</td>
<td><input type="text" name="contents"></td>
</tr>
</table>
</form>
</div>
<div id="modify" style="display: none">
<form name="form2" method="post" action="save.do">
<table>
<tr>
<td colspan="2"><input type="hidden" name="id"></td>
</tr>
<tr>
<td>이름</td>
<td><input type="text" name="writer"></td>
</tr>
<tr>
<td>내용</td>
<td><input type="text" name="contents"></td>
</tr>
</table>
</form>
</div>
위와 같이 페이지가 구성되어 있을 때 form2의 writer에 값을 지정할 때는
document.forms["form2"].elements["writer"].value = "내 이름"
[참고] Using JavaScript to access form objects when there are multiple forms