2017-04-01 63 views
-6

我正嘗試創建此腳本,其中用戶只能從類別1中選擇一個選項,從類別2中選擇一個選項,然後單擊提交以生成鏈接。 如果我希望這種方式能夠在線生活,並且無需服務器就可以完成客戶端操作,那麼最好的方法是什麼? Javascript用戶輸入

+0

我是這個網站的全新品牌,但是我確實上傳了一張照片,希望能解釋任何問題。 – zackheredia

+0

Stackoverflow不是*「如何」*教程服務 – charlietfl

+0

您應該去SO –

回答

-1

使用單選按鈕

<form> 
    <fieldset id="group1"> 
     <input type="radio" value="" name="group1"> 
     <input type="radio" value="" name="group1"> 
    </fieldset> 

    <fieldset id="group2"> 
     <input type="radio" value="" name="group2"> 
     <input type="radio" value="" name="group2"> 
     <input type="radio" value="" name="group2"> 
    </fieldset> 
</form> 

這個答案是從這裏Multiple radio button groups in one form

如果您編輯代碼一點你(你使用值1和值2作爲字符串中的鏈接)

<form> 
     <fieldset id="group1" style="float:left;"> 
      <input type="radio" value="" name="group1"> 
      <input type="radio" value="" name="group1"> 
     </fieldset> 

     <fieldset id="group2" style="float:right;left:100px;"> 
      <input type="radio" value="" name="group2"> 
      <input type="radio" value="" name="group2"> 
      <input type="radio" value="" name="group2"> 
     </fieldset> 
     <button onclick="myFunction();">Submit</button> 
    </form> 

<script> 
function myFunction() { 
value1 =document.getElementById('group1').value ; 
value2 =document.getElementById('group2').value ; 
} 
</script>