powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Сабмит формы из всплывающего окна
10 сообщений из 10, страница 1 из 1
Сабмит формы из всплывающего окна
    #36423943
janklyn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
подскажите пожалуйста .
у меня есть основная форма + кнопка , по клику на кнопке необходимо всплывающее окошко. в нем кнопку сабмит основной формы:
пытаюсь следующим образом сделать:
на основной форме имею следующее:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
	<input type="image" name="formSubmit" id="formSubmit" value="Assigned"
	 onClick="javascript:win_open(this);return false;"/> 

        function submitForm(sel) {
		var form = document.getElementById('test');
			
		if (form != null) {
			 if (sel.name == "formSubmit") {
				form.action = "saveSomething.action";
			} 
			form.submit();
		}
	}
    

создаю всплывающее окно с кнопкой
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
      function win_open(sel){
		windop=window.open("","mywin","width=200,height=120");
		windop.document.open();
		windop.document.write("<html><head><title>.....Demo window.....</title>");
		windop.document.write("</head><body text='#ffffff'");
		windop.document.write("<center></center>");
		windop.document.write("<center><form  name='for' >
              <input type='button' value='Закрыть' onClick='window.opener.submitForm('formSubmit')'></form></center>")
		windop.document.write("</body></html>");

		windop.document.close();
		}
	
Но сабмит формы не происходит
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36423955
ShSerge
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Сделайте всё по человечески. Без всяких write. На отдельной странице. Найдёте свою ошибку.
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36423964
janklyn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
я совсем не владею джава скриптом.. смотрел по примерам. подскажите если не затруднит
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36424230
Фотография krvsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
janklynя совсем не владею джава скриптом.. смотрел по примерам. подскажите если не затруднит
Тогда зачем тебе такие извращения?
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36426345
neznau
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
чуть-чуть подправил ваш код

Код: plaintext
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.
<html><head><title></title></head><body>

<form id="forma" onsubmit="alert('sumbitted...');" action="http://www.yandex.ru/yandsearch" method="GET">
	<input type="button" name="btn" value="button" onClick="win_open(this.form.id)"/> <br>
	<input type="textarea" name="text" value="javascript window opener"/>
</form>
	 
<script type="text/javascript" language="javascript">
function submitForm(id) {
	var form = document.getElementById(id);		
	if (form!=null) {
		form.submit();
	}
}

function win_open(formId){
	windop=window.open("","mywin","width=200,height=120");
	
	windop.document.write("<html><head><title>.....Demo window.....</title></head><body text='#ffffff'><center>");
    windop.document.write("<input type='button' value='Закрыть' onClick=\"window.opener.document.getElementById(\'"+formId+"\').submit();window.close()\">")
	windop.document.write("</center></body></html>");
	
	windop.document.close();
}
</script>

</body></html>
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36433789
janklyn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо большое. помогло мне разобраться с проблемой.. но немного все переиграла.. и рассмотрела 2 варианта:
- с window.open;
- c window.showModalDialog.
В первом случае реализовала следующим образом, все работает на ура... но вот решила что более правильней будет использовать showModalDialog.. но с ним возникли проблемы.. а более менее полной информации не нашла..
в основном окне:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
<form id="saveTicket" name="saveTicket" onsubmit="return checkForm(this);" action ="" method="POST"> 
    <select name="assignedGroupId" id="assignedGroupId">
	<s:iterator value="groups">
		<option value="${id}" ${id eq assignedGroupId ? selecteditem: ''} >
                     <s:property value="description " />
                </option>
	</s:iterator>
    </select>
    <input type="image" onClick="javascript:win_open();return false;"/> 
</form>
открываем всплывающее окно:(не модальное)
Код: plaintext
1.
2.
	function win_open(sel){
	       windop=window.open("assignedGroupList.action","mywin","width=200,height=120, ");
      	}
всплывающее окно:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
<form id="assignedGroups" name="assignedGroups" onsubmit=" " action ="" method="POST">
 <select name="assignedGroupId" id="assignedGroupId">
	<s:iterator value="groups">
		<option value="${id}" ${id eq assignedGroupId ? selecteditem: ''} >
                     <s:property value="description " />
                </option>
	</s:iterator>
 </select>
  <input type="image" name="formAssignedSubmit" id="formAssignedSubmit"onclick="assigned_submit();return false;"/> 	
</form>
обработчик кнопки и закрытие всплывающего окна:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
function assigned_submit()
    {
	var user_idx = document.assignedGroups.assignedGroupId.selectedIndex; 
	var user_id = document.assignedGroups.assignedGroupId.options[user_idx].value;
	window.opener.document.saveTicket.assignedGroupId.value =  user_id;
	window.opener.document.saveTicket.action = "${ctxContext}/TicketAssigned.action";
        window.opener.document["saveTicket"].submit();
        window.close();
    }
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36433817
janklyn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
у showModalDialog нет такого свойства как opener .. не пойму как могу вернуть данные в родительское окно.. нашла несколько заметок на эту тему.. только не понимаю.. если не сложно. объясните мне пожалуйста.
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36434813
Фотография Ренат
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
попробуй так:
Код: plaintext
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.
29.
30.
31.
32.
<style>
.confirm{
    position:fixed;
    left:200px;
    top:200px;
    width:300px;
    height:200px;
    padding:10px;
    border:1px solid # 555555 ;
    border-right:2px solid # 555555 ;
    border-bottom:2px solid # 555555 ;
    text-align:center;
}
</style>
<script language="JavaScript">
function win_open(id){
    var confirm = document.createElement('div');
    var button = document.createElement('input');
    confirm.className = 'confirm';
    button.type = 'button';
    button.value = 'SEND';
    button.onclick = function (){
        document.getElementById(id).submit();
        return false;
    }
    confirm.appendChild(button);
    document.body.appendChild(confirm);
}
</script>
<form id="forma" onsubmit="alert('sumbitted...');" action="" method="GET">
    <input type="button" name="btn" value="button" onclick="win_open(this.form.id)"/> <br>
    <input type="textarea" name="text" value="javascript window opener"/>
</form>
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36434926
neznau
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
janklynу showModalDialog нет такого свойства как opener .. не пойму как могу вернуть данные в родительское окно.. нашла несколько заметок на эту тему.. только не понимаю.. если не сложно. объясните мне пожалуйста.
На счёт showModalDialog не знаю, но если нужно заблокировать окно с основной формой, можно попробовать сделать прозрачный див, блокирующий нажатия мыши на страницу. правда табом прыгать по элементам можно...

Код: plaintext
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.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
<html><head><title></title>
<style>
.block{
	position:absolute;
	top:0px;
	left:0px;
	width: 100 %;
	height: 100 %;
	background-color: # 990099 ;
    opacity:  0 . 70 ;
    filter: alpha(opacity= 70 );
	z-index:  100000 ;
}
</style>
</head><body>
<div id="block" style="display:none;"></div>
<form id="forma" onsubmit="alert('sumbitted...');" action="http://www.yandex.ru/yandsearch" method="GET">
	<input type="button" name="btn" value="button" onClick="win_open(this.form.id)"/> <br>
	<input type="textarea" name="text" value="введите код на картинке"/>
</form>
	 
<script type="text/javascript" language="javascript">
function submitForm(id) {
	var form = document.getElementById(id);		
	if (form!=null) {
		form.submit();
	}
}

function win_open(formId){
	var tmpDiv=document.getElementById('block');
	if (tmpDiv!=null) {
		tmpDiv.className='block';
		tmpDiv.style.display='';
	}
	
	windop=window.open("","mywin","width=200,height=120");
	windop.document.write("<html><head><title>.....Demo window.....</title></head><body text='#ffffff'><center>");
    windop.document.write("<input type='button' value='Закрыть' onClick=\"window.opener.document.getElementById('block').style.display='none';window.opener.document.getElementById(\'"+formId+"\').submit();window.close()\">")
	windop.document.write("</center></body></html>");
	windop.document.close();
}
</script>
<p>dfqadfgaf</p>

</body></html>
...
Рейтинг: 0 / 0
Сабмит формы из всплывающего окна
    #36435166
Фотография krvsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
janklynу showModalDialog нет такого свойства как opener .. не пойму как могу вернуть данные в родительское окно..
Вот таким макаром...

Файл temp.html

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type='text/javascript'>
function Go() {
	var val=window.showModalDialog('tmp.html')
	alert(val)
}
</script>
</head>
<body>
	<input type='button' value='Go' onclick='Go()'>
</body>
</html>

Файл tmp.html

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
<html>
<head>
<title>Test</title> 
<script type='text/javascript'>
function Send() {
	var val=document.getElementById('data').value
	window.returnValue=val
	window.close()
}
</script>
</head>
<body>
	<form>
		<input type='text' id='data' />
		<input type='button' value='Send' onclick='Send()' />
	</form>
</body>
</html>
...
Рейтинг: 0 / 0
10 сообщений из 10, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Сабмит формы из всплывающего окна
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]