2017-11-24 11 views
-2

나는 html 사이트를 만듭니다. 사이트에 질문이 있습니다. 나는 form으로 만들었습니다. 버튼을 클릭 한 후, 같은 페이지에서 모든 답변을보고 싶습니다. 나는 경고하고 싶지 않습니다. 내가 어떻게 해?단추 뒤에 동일한 페이지에 html 양식 값이 표시됩니다.

철자 오류에 대해 사과드립니다.

\t <script> 
 
\t \t \t function findSelection() 
 
\t \t \t { 
 
\t \t \t \t 
 
\t \t \t \t var serieList=document.getElementsByName('serie') 
 
\t \t \t \t for (var i=0; i<serieList.length;i++) 
 
\t \t \t \t { 
 
\t \t \t \t if(serieList[i].checked) 
 
\t \t \t \t \t { 
 
\t \t \t \t \t 
 
\t \t \t \t \t } 
 
\t \t \t \t } 
 
\t \t \t \t 
 
\t \t \t \t var markaList=document.getElementsByName('marka') 
 
\t \t \t \t 
 
\t \t \t \t for (var i=0; i<markaList.length;i++) 
 
\t \t \t \t { 
 
\t \t \t \t if(markaList[i].checked) 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t alert(markaList[i].value) 
 
\t \t \t \t \t } 
 
\t \t \t \t } 
 
\t \t \t \t 
 
\t \t \t \t var yerList=document.getElementsByName('yer') 
 
\t \t \t \t 
 
\t \t \t \t for (var i=0; i<yerList.length;i++) 
 
\t \t \t \t { 
 
\t \t \t \t if(yerList[i].checked) 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t alert(yerList[i].value) 
 
\t \t \t \t \t } 
 
\t \t \t \t } 
 
\t \t \t \t 
 
\t \t \t \t var nasilList=document.getElementsByName('nasil') 
 
\t \t \t 
 
\t \t \t \t for (var i=0; i<nasilList.length;i++) \t 
 
\t \t \t \t { 
 
\t \t \t \t if(nasilList[i].checked) 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t alert(nasilList[i].value) 
 
\t \t \t \t \t } 
 
\t \t \t \t } 
 
\t \t \t \t 
 
\t \t \t \t 
 
\t \t \t } 
 
\t \t \t 
 
\t \t \t 
 
\t </script> 
 
\t
<html> 
 
\t <head> 
 
\t \t <title>Web Tasarım Anketi </title> 
 
\t 
 
\t </head> 
 
\t 
 
\t <body style="background-color:#d3ea93"> 
 
\t <center> <h1 style="color:red"> ANKET </h1> </center> 
 

 
\t <form > 
 
\t \t <fieldset><legend>Soru 1 </legend> 
 
\t \t \t En sevdiğiniz yabancı dizi? </br> 
 
\t \t \t \t <label> \t <input type="radio" name="serie" value="Game of Thrones">Game of Thrones </label> 
 
\t \t \t \t <label> \t <input type="radio" name="serie" value="Person of İnterest">Person of Interest </label> 
 
\t \t \t \t <label> \t <input type="radio" name="serie" value="South Park">South Park </label> \t 
 
\t \t \t \t <label> \t <input type="radio" name="serie" value="Black Mirror">Black Mirror </label> \t 
 
\t \t </fieldset> 
 
\t </form> \t 
 
\t 
 
\t <form > 
 
\t \t <fieldset><legend>Soru 2 </legend> 
 
\t \t \t En sevdiğiniz bilgisayar markası? </br> 
 
\t \t \t \t <label> \t <input type="radio" name="marka" value="Asus">Asus </label> 
 
\t \t \t \t <label> \t <input type="radio" name="marka" value="HP">HP </label> 
 
\t \t \t \t <label> \t <input type="radio" name="marka" value="Toshiba">Toshiba </label> 
 
\t \t \t \t <label> \t <input type="radio" name="marka" value="Dell">Dell </label> 
 
\t \t </fieldset> 
 
\t \t 
 
\t </form> 
 
\t 
 
\t <form> 
 
\t \t <fieldset><legend>Soru 3 </legend> 
 
\t \t \t Nerede yaşamak istersiniz?</br> 
 
\t \t \t \t <label> \t <input type="radio" name="yer" value="Türkiye">Türkiye </label> 
 
\t \t \t \t <label> \t <input type="radio" name="yer" value="Mars">Mars </label> 
 
\t \t \t \t <label> \t <input type="radio" name="yer" value="Avustralya">Avustralya </label> 
 
\t \t \t \t <label> \t <input type="radio" name="yer" value="Yeni Zelanda">Yeni Zelanda </label> 
 
\t \t </fieldset> 
 
\t </form> 
 
\t 
 
\t <form> 
 
\t \t <fieldset><legend>Soru 4 </legend> 
 
\t \t \t Nasıl ölmek istersiniz?</br> 
 
\t \t \t \t <label> \t <input type="radio" name="nasil" value="Araba Kazasında ">Araba Kazası </label> 
 
\t \t \t \t <label> \t <input type="radio" name="nasil" value="Uzay Boşluğunda">Uzay Boşluğunda </label> 
 
\t \t \t \t <label> \t <input type="radio" name="nasil" value="Ecelimle">Ecelimle </label> 
 
\t \t \t \t <label> \t <input type="radio" name="nasil" value="Maganda Kurşunu">Maganda Kurşunu </label> 
 
\t \t </fieldset> 
 
\t </form> 
 
\t 
 
\t <input type="button" id="btnKaydet" value="Kaydet" onclick="findSelection()"></input> 
 
\t \t 
 
\t 
 
\t </body> 
 

 
</html>

답변

-1

당신이 JQuery와 통해 그것을 할 ID를 모든 필드를

을주고이

<script> 
    $(document).ready(function() { 
$("#Button1).click(function(){ 
$("#abc1").val($("#abc").val()); 
}) 
</script> 
<body> 
<input type="text" id="abc" /> 
<input id="Button1" type="button" value="button" /> 
<input type="text" id="abc1" /> 
</body> 
+0

이, JQuery와하지 자바 스크립트 – ThisGuyHasTwoThumbs

+0

그래 jQuery로는 쉽게 연산이 지정하는 경우 자바 스크립트가 다음 자바 스크립트를 사용 – eraufi

+0

자바 스크립트보다 그러나 그가 단지 자바 스크립트를 사용하여 언급하지 않았다 JQuery와의 xD에게 – ThisGuyHasTwoThumbs

0
당신이 이것을 달성하기 위해 자바 스크립트를 사용할 수

처럼 쓰기하지만 궁극적으로 당신이 원하는 수 있습니다 PHP와 같은 프로그래밍 언어 server-side을 배우십시오. 나에게 PHP는 최선의 선택이다.

Google 양식을 작성하고 mozilla 장치 문서를 클릭하면 action이라는 속성이 표시됩니다.이 속성은 양식이 어디로 가야할지 또는 무엇을 할 것인지 (인라인 자바 스크립트로 작성하지만이 작업을 적극 권장합니다)라고 말합니다. method이라는 속성도 있습니다. 메서드는 폼이 입력 값을 처리하는 방법을 담당합니다. 가장 일반적인 두 값은 postget입니다.

저는 보통 데이터를 스크립트에 게시하기 때문에 post만을 사용합니다. 귀하의 form.php 페이지에서 다음

<form method="post" action="<?php echo $this->getFormAction(); ?>">

:

가장 일반적인 사용은 그러나

<form method="post" action="/area/scripts/post/form.php">

같은 것이, MVC와 정말 재미 점점 더 좋아 보일 것입니다 당신은 데이터를 처리합니다. 무슨 뜻인지 알려면 지금 form.php에 넣으십시오.

<?php 
    var_dump($_POST) ; 

양식 데이터가 표시됩니다.

동일한 페이지에 표시 할 생각으로 다시 연결하려면 아약스를 사용할 수도 있지만 이는 사이트에 jquery를 포함시키는 것을 의미합니다. 그것은 100 % 삶을 편하게 해주지 만 사이트 크기는 증가합니다. 물론 .min 스크립트를 선택할 수는 있지만 모든 페이지에 포함됩니다.

어쨌든. 순수 HTML을 사용하여 가능하지 않은지, 자바 스크립트는 브라우저 측 프로그래밍 언어이며 전적으로 동적으로 값을 할당 할 수 있는지 확실하지 않지만 아마 자바 스크립트 전문가는 아닙니다. 그렇지 않기 때문에

나는 그것도 또한

(당신이 규칙을 따라 그것을 할 경우 제대로 안전 코드를 사용하여)이 확보 만들면서이 PHP를 사용하는 것이 좋습니다, 나는 실제 답변으로 주석으로이 선호 문제 또는 관련 태그를 직접 처리 할 수 ​​있지만 글자 수 제한은 이와 같은 주석으로는 충분하지 않습니다.선호하는 경우 downvote 부담없이 당신이 문자열을 CONCAT하는 +을 사용하여 자바 스크립트의 변수를 결합하려면 코멘트

을보고 난 후에

업데이트 -3되면 어떻게 간단하게 제거 할 수 있습니다.

예.

var message = document.getElementById('myId') + ' ' + document.getElementById('myIdTwo'); 

alert(message); 

이것은 사용법에 대한 한 가지 예일 뿐이므로이 방법을 사용해야합니다.

행운을 빈다.

+0

답변 해 주셔서 감사합니다. 아직 PHP를 배우지 못했습니다. 자바 스크립트에 대한 충분한 지식이 없습니다. 새로운 것을 배우는 중입니다. 내가 어떻게 자바 스크립트를 사용하여 할 수 있습니까?. 나는 "경고"와 하나씩 대답을 표시하지만 그 일을하고 싶지 않아. 나는 하나의 대답으로 표시하고 싶습니까? – volkan

+0

@volkan 아아, 혼란에 빠져서 죄송합니다. 내 대답을 수정하겠습니다. – ThisGuyHasTwoThumbs