簡體   English   中英

如何通過php或jquery中的url get變量設置passord字段值

[英]How to set passord field value by url get variable in php or jquery

我可以設置用戶名字段值,但不能設置密碼字段值。

我敢肯定<input type="password" value="value" />可以在大多數瀏覽器中使用。

在這里看http://www.w3schools.com/html/html_forms.asp 使用type="password"而不是type="input"

假設您有一個輸入字段:

<input type="password" name="ooxx" />

並使用jQuery,您可以在運行時設置其值:

// 333 is the new value
jQuery("input[type='password']").val(333)

在此處查看實時示例: http : //jsfiddle.net/AeJjy/

同樣,您也可以使用下面的方法從url獲取值。

/**
 * Usage:  given :  http://some.site.com?para1=hi 
 * para1 = params("para1")     => para1 = "hi"
 * @param {Object} name
 */
function params(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return ""; 
  else
    return results[1];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM