如何提交?

时间:2018-11-30 02:51:23

标签: javascript puppeteer

我有下面的代码,我正在使用puppeteer提交此表单内容,但是在输入值之后,它会重新加载页面,并且字段变为空白,什么也没有发生,如何提交?

private Mono<Void> test(Long gId, UUID pId) {
    Mono<UUID> nId = pDao.findNId(pId);
    Mono<List<String>> channels = nId.flatMapMany(pDao::findChannels).collectList();
    Mono.zip(nId, channels)
           .flatMap(t -> {
               System.out.println(t.getT1());
               return kafkaPublisher.publishToTopic(gId, t.getT1().toString(), t.getT2());
           }).block();
    return Mono.empty();

4 个答案:

答案 0 :(得分:0)

尝试一下:

<a href="#" onclick="this.form.submit();" tabindex="2">

或者,使用jQuery:

<a href="#" onclick="$(this).closest('form').submit();" tabindex="2">

您可能还需要将href="#"替换为href="javascript:void(0);"

希望这会有所帮助。

答案 1 :(得分:0)

我认为您在代码中缺少一些东西,例如- 1.动作属性(表示您要执行的操作,即单击提交时。 2. Submitform方法定义也丢失了

请参见下文,我如下更新了您的代码-

IF OBJECT_ID('tempdb..#Temp1') IS NOT NULL
DROP TABLE #Temp1

IF OBJECT_ID('tempdb..#Temp2') IS NOT NULL
DROP TABLE #Temp2    

IF OBJECT_ID('tempdb..#Temp3') IS NOT NULL
DROP TABLE #Temp3    

CREATE Table #Temp1 ( 
Id int,
Name NVARCHAR(64),
StudentNo INT NULL,
ClassCode NVARCHAR(8) NULL, 
Section  NVARCHAR(8) NULL, 
)


INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(1,'Joe',123,'A1', 'I')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(1,'Joe',123,'A1', 'I')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(2,'Harry',113,'X2', 'H')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(2,'Harry',113,'X2', 'H')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(3,'Elle',121,'J1', 'E1')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(3,'Elle',121,'J1', 'E')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(8,'Jane',191,'A1', 'E')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(5,'Silva',811,'S1', 'SE')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(6,'Juan',411,'S2', 'SE')
INSERT INTO #Temp1 (Id, Name,StudentNo,ClassCode,Section) Values(7,'Carla',431,'S2', 'SE')

;WITH CTE AS (
    select 
ROW_NUMBER() over (partition by Id                                          
                                , StudentNo                                                                                 
                                order by Id, StudentNo)as Duplicate_RowNumber
, * from #Temp1 )

select  t1.Id,t1.Name,t1.StudentNo,t1.Section,t1.ClassCode 
INTO #Temp2 
from CTE as c INNER JOIN #Temp1 as t1 ON t1.Id = c.Id                                           
                                and t1.StudentNo = t1.StudentNo
                                and c.Duplicate_RowNumber >1

-- this will have 6 rows all the duplicates are included 
--select * from #Temp2 


-- this is for output clause 
DECLARE @inserted Table (Id int,
                        Name NVARCHAR(64),
                        StudentNo INT NULL,
                        ClassCode NVARCHAR(8) NULL, 
                        Section  NVARCHAR(8) NULL)


DELETE FROM  #temp1 
OUTPUT deleted.Id , deleted.Name ,deleted.StudentNo ,deleted.ClassCode ,deleted.Section into @inserted
 WHERE EXISTS ( SELECT * FROM #Temp2 as t2 
                                where  #temp1.Id = t2.Id 
                                        and #temp1.Name = t2.Name
                                            and #temp1.StudentNo = t2.StudentNo                                                      
                                            and #temp1.ClassCode = t2.ClassCode
                                            and #temp1.Section = t2.Section)
-- this is to check what is delete so that i can join it and update the table temp1                                         
select * from @inserted

答案 2 :(得分:0)

<form name="Logon" method="POST" autocomplete="off" onsubmit="return false;" id="Myform"> 
<input type="password" name="textField" title="* textField" id="textField" maxlength="32">
<a href="#" id="submit" tabindex="2">
<img src="/images/btn_submit_def.gif" border="0" alt="Submit" title="Submit"></a>
</form>

jQuery:

$('#submit').click(function(event){
          event.preventDefault();

          $('#Myform').submit();
});

答案 3 :(得分:0)

您可以做到

<body>
        <form name="Logon" method="POST" autocomplete="off">
            <input type="password" name="textField" title="* textField" id="textField" maxlength="32">
            <a href="#" onclick="func(this)">
                <img src="/images/btn_submit_def.gif" border="0" alt="Submit" title="Submit">
            </a>
        </form>
    </body>

    <script>
        function func(ahr) {
            ahr.innerHTML = "very good"
            // you can do whatever you want
        }
    </script>