๊ด€๋ฆฌ ๋ฉ”๋‰ด

bom's happy life

[JS]๋™์  Form ์ƒ์„ฑํ•˜๊ธฐ + ์ˆจ๊ฒจ์„œ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ์ด๋™ํ•˜๊ธฐ ๋ณธ๋ฌธ

Deveolpment Study๐Ÿ—‚๏ธ/Javascript

[JS]๋™์  Form ์ƒ์„ฑํ•˜๊ธฐ + ์ˆจ๊ฒจ์„œ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ์ด๋™ํ•˜๊ธฐ

bompeach 2023. 5. 31. 10:54

ajax๋กœ ๋ฐ์ดํ„ฐ ๋ณด๋‚ด๋ ค๋‹ค๊ฐ€ ์–ด์ฐจํ”ผ ํŽ˜์ด์ง€ ์ด๋™์„ ํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์—

(๋น„๋™๊ธฐ ๋ฐฉ์‹์„ ๊ตณ์ด ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋˜์„œ)

๋™์  form์„ ์ƒ์„ฑํ•˜๊ณ  ์ˆจ๊ฒจ์„œ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ์ด๋™ํ•ด์ฃผ์—ˆ๋‹ค!

 

์˜ˆ์•ฝํ•˜๊ธฐ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ๊ฐ€์ง€๊ณ  ๊ฐˆ ์ •๋ณด๋“ค form์— ๋„ฃ์–ด์„œ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ๋ณด๋‚ด๊ธฐ!!

function placeRentAdd(rentDate,rentTime) {
		//alert(rentDate);
		//alert(rentTime);
		confirm("์˜ˆ์•ฝํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?");
		
    	var form = document.createElement("form");
    	form.setAttribute("charset", "utf-8");  
    	form.setAttribute("method", "POST");  //๋ณด๋‚ผ ๋ฐฉ์‹ POST
    	form.setAttribute("action", "/rentPlaceForm.do");  //์š”์ฒญํ•  ์ฃผ์†Œ
    	
    	var rentInfo = document.createElement("input");
        rentInfo.setAttribute("placeNm", "${placeNm}");
        rentInfo.setAttribute("rentDate", rentDate);
        rentInfo.setAttribute("rentTime", rentTime);
        form.appendChild(rentInfo);
        
        form.style.display = "none";  //ํผ ์ˆจ๊ธฐ๊ธฐ
        
        document.body.appendChild(form);
        form.submit();
}