html
  • asp.net
  • forms
  • dotnetnuke
  • 2017-07-17 84 views 0 likes 
    0

    我試圖設置一個窗體等提交一個新的窗口打開注入輸入字段到URL。目前它只是刷新頁面,所以我不太清楚我在這裏錯過了什麼,任何建議都是有幫助的!如何將表單輸入字段注入到URL中?

    !! ---更新--- !!

    因爲IM使用DNN的網站是的.aspx,整個頁面是一種形式(所以在初論我嘗試創建一個表單內的形式,這就是爲什麼它不會工作)apparntly我需要做的:

    onClick="this.form.action='https://www.paypal.com/cgi-bin/webscr';this.form.submit();"

    <form method="GET" target="_blank" action="https://www.youtube.com/" > 
     
    <input id="street_1" name="street_1" placeholder="" type="text" /> 
     
    <input id="street_2" name="street_2" placeholder="" type="text" /> 
     
    <input id="suburb" name="suburb" placeholder="" type="text" /> 
     
    <input id="City" name="City" placeholder="" type="text" /> 
     
    <input id="Postcode" name="Postcode" placeholder="" type="text" /> 
     
    <button type="submit" id="submit">Submit</button> 
     
    </form>

    在此先感謝!

    +1

    是的,因爲它是一個提交按鈕 - 它會自動刷新頁面此後您的客戶端腳本無法運行。您需要使用ajax來加載表單中的表單 - 您可以使用ASP.NET UpdatePanel或使用$ .ajax()將數據加載到使用jQuery/javascript添加的新表單標記中。 – Yatin

    回答

    0

    對於那些誰是好奇..我繼承人如何完成我的任務:

    多虧了的jsfiddle我發現這裏http://jsfiddle.net/t8kAS/

    <fieldset> 
        <legend>Customize Link</legend> 
        Value 1: <input type="text" id="street_1" class="jsCustomField" /><br /> 
        Value 2: <input type="text" id="street_2" class="jsCustomField" /><br /> 
        Value 3: <input type="text" id="suburb" class="jsCustomField" /><br /> 
        Value 4: <input type="text" id="city" class="jsCustomField" /><br /> 
        Value 5: <input type="text" id="postcode" class="jsCustomField" /> 
    </fieldset> 
    <a href="https://www.randomurl.com/stuff/id?street_1=&street_2=&suburb=&city=&postcode=" id="dynLink" target="_blank">Click Me!</a> 
    
        $(function() { 
         var linkTemplate = "https://www.randomurl.com/stuff/id?street_1={0}&street_2={1}&suburb={2}&city={3}&postcode={4}", 
          $input1 = $("#street_1"), 
          $input2 = $("#street_2"), 
          $input3 = $("#suburb"), 
          $input4 = $("#city"), 
          $input5 = $("#postcode"), 
          $dynLink = $("#dynLink") 
    
        $(".jsCustomField").on("change", function() { 
         var customLink = linkTemplate.replace("{0}", $input1.val()) 
                 .replace("{1}", $input2.val()) 
                 .replace("{2}", $input3.val()) 
                 .replace("{3}", $input4.val()) 
                 .replace("{4}", $input5.val()); 
         $dynLink.attr("href", customLink); 
        }); 
    
    
    }); 
    
    相關問題