获取输入框以更改HTML中的URL

时间:2016-12-09 18:16:46

标签: javascript jquery html

嗨所以我有一个带有按钮的输入框,当点击进入网址时。我想要它,所以无论用户输入什么,它都会转到url +输入框中添加的单词。所以,让我们说默认的google.com/search/?q=然后用户输入" cat"它将是google.com/search/?q=cat



  <input type= "button" onclick="location.href=\
  'http://www.google.com/search/?q=';"\
   value="Search Google Images"/><br><br>

<br><br>	Search item:<input type="text" id="dropdownID"><br><br>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

使用document.getElementById('dropdownID').value附加输入字段的值:

<input type="button" onclick="location.href='http://www.google.com/search/?q='+document.getElementById('dropdownID').value" value="Open Testrail Test Plan for Modiciation" />
<br>
<br>

<br>
<br>Search item:
<input type="text" id="dropdownID">
<br>
<br>

答案 1 :(得分:0)

<input type= "button" onclick="loadUrl()" value="Search Google Images"/>
<br><br><br><br>  Search item:<input type="text" id="dropdownID"><br><br>

<script>
  function loadUrl() {
    location.href = 'http://www.google.com/search/?q=' + document.getElementById('dropdownID').value;
  }
</script>

答案 2 :(得分:0)

我会使用jquery:

https://jsfiddle.net/dqz1pvux/13/

df.groupby('label', as_index=False).apply(lambda x: x.sample(2)) \
                                   .reset_index(level=0, drop=True)
Out: 
           0         1         2         3         4  label
s1  0.433731  0.886622  0.683993  0.125918  0.398787      1
s1  0.719834  0.435971  0.935742  0.885779  0.460693      1
s2  0.324877  0.962413  0.366274  0.980935  0.487806      2
s2  0.600318  0.633574  0.453003  0.291159  0.223662      2
s3  0.741116  0.167992  0.513374  0.485132  0.550467      3
s3  0.301959  0.843531  0.654343  0.726779  0.594402      3
相关问题