-2
Mới! Lưu câu hỏi hoặc câu trả lời và sắp xếp nội dung yêu thích của bạn. Tìm hiểu thêm.
Learn more.
Tôi cần lấy giá trị của một trường văn bản và lưu nó vào một biến nhưng không có nút gửi.
Như thế này ở đây: //streambadge.com/
Như bạn có thể thấy văn bản bạn viết trong bước hai sẽ tự động được thêm vào văn bản đầu ra. Tôi có thể làm cái này như thế nào?
hỏi ngày 17 tháng 1 năm 2014 lúc 17:21Jan 17, 2014 at 17:21
1
Bạn có thể làm điều đó bằng JavaScript /jQuery [tập lệnh trang web máy khách].
Bản demo trực tiếp: //jsfiddle.net/5y9mg/51/
//jsfiddle.net/5Y9mG/51/
HTML:
You will have output here :
Jquery:
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
Bạn muốn lưu giá trị này trong biến PHP thì bạn cần gọi AJAX [mà không gửi biểu mẫu của bạn] hoặc bạn cần gửi biểu mẫu.
Đối với Ajax cơ bản, bạn có thể đọc điều này: //www.tutorialspoint.com/jquery/ajax-jquery-post.htm
//www.tutorialspoint.com/jquery/ajax-jquery-post.htm
Liên kết jQuery hữu ích để tìm hiểu: Tài liệu API: //api.jquery.com/
API documentation:
//api.jquery.com/
Cơ bản: //learn.jquery.com/about-jquery/how-jquery-works/
Đã trả lời ngày 17 tháng 1 năm 2014 lúc 17:27Jan 17, 2014 at 17:27
Awlad Litonawlad LittonAwlad Liton
9.2682 Huy hiệu vàng26 Huy hiệu bạc52 Huy hiệu Đồng2 gold badges26 silver badges52 bronze badges
5
Sử dụng onchange
hoặc onkeyup
để phát hiện khi người dùng gõ.
Đã trả lời ngày 17 tháng 1 năm 2014 lúc 17:22Jan 17, 2014 at 17:22
HalcyonhalcyonHalcyon
56.6K10 Huy hiệu vàng87 Huy hiệu bạc126 Huy hiệu đồng10 gold badges87 silver badges126 bronze badges
5 năm trước
Darren tại Sullivan Dot Net
Tim tại Timpauly Dot Com ¶
Name:
Email:
Keli tại Kmdsz Dot Ro ¶
Arjini tại Mac Dot Com ¶
mattij tại nitro fi no at no dot no ¶
Làm thế nào tôi có thể nhận được giá trị trường đầu vào trong PHP mà không cần gửi?:
PHP $ a = $ _get ["housemodel"]; if [$ a ''] {if [$ a == $ model1] {echo ""; } if if [$ a == $ model2] {echo ""; } if if [$ a == $ model3] {echo ""; ...
Làm thế nào để chúng tôi nhận được giá trị hộp văn bản trong một biến PHP mà không cần một nút gửi hoặc nhấp?
trên ['keyUp', function [] {// trên sự kiện keyup trong trường đầu vào của bạn $ ["#nhu cầu"]. ]; Bạn muốn lưu giá trị này trong biến PHP thì bạn cần gọi AJAX [mà không gửi biểu mẫu của bạn] hoặc bạn cần gửi biểu mẫu.
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
2$ _ Trong PHP là gì?: If an external variable name begins with a valid array syntax, trailing characters are silently ignored. For example,
3 becomes$[ document ].ready[function[] { $['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field $["#needs"].append[this.value];// append values from input field }]; ];
4.$[ document ].ready[function[] { $['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field $["#needs"].append[this.value];// append values from input field }]; ];
PHP $ _POST là một biến siêu toàn cầu PHP được sử dụng để thu thập dữ liệu biểu mẫu sau khi gửi biểu mẫu HTML với Phương thức = "Post". $ _POST cũng được sử dụng rộng rãi để vượt qua các biến.
Biến $$ trong PHP là gì?
PHP | $ vs $$ toán tử $ var_name = "Hello World!"; $ Var_name là một biến bình thường được sử dụng để lưu trữ một giá trị. Nó có thể lưu trữ bất kỳ giá trị nào như Integer, Float, Char, String, v.v. Mặt khác, $$ var_name được gọi là biến tham chiếu trong đó $ var_name là một biến bình thường.
Mẫu HTML [GET và POST]
Khi một biểu mẫu được gửi đến tập lệnh PHP, thông tin từ biểu mẫu đó sẽ tự động cung cấp cho tập lệnh. Có một số cách để truy cập thông tin này, ví dụ: ví dụ:setcookie[] function. Cookies are part of the HTTP header, so the SetCookie function must be called before any output is sent to the browser. This is the same restriction as for the header[] function. Cookie data is then available in the appropriate cookie data arrays, such as $_COOKIE as well as in $_REQUEST. See the setcookie[] manual page for more details and examples.
Lưu ý: Kể lần lượt là Php 7.2.34, 7.3.23 và 7.4.11, tên của cookie đến không còn được mã hóa URL vì lý do bảo mật.: As of PHP 7.2.34, 7.3.23 and 7.4.11, respectively, the names of incoming cookies are no longer url-decoded for security reasons.
Nếu bạn muốn gán nhiều giá trị cho một biến cookie, bạn có thể gán nó dưới dạng một mảng. Ví dụ:
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
5Điều đó sẽ tạo ra hai cookie riêng biệt mặc dù Mycookie bây giờ sẽ là một mảng duy nhất trong tập lệnh của bạn. Nếu bạn muốn chỉ đặt một cookie có nhiều giá trị, hãy xem xét sử dụng serialize [] hoặc leasplode [] trên giá trị trước.serialize[] or explode[] on the value first.
Lưu ý rằng cookie sẽ thay thế cookie trước đó cùng tên trong trình duyệt của bạn trừ khi đường dẫn hoặc miền khác nhau. Vì vậy, đối với một ứng dụng giỏ hàng, bạn có thể muốn giữ một quầy và vượt qua điều này. I E.
Ví dụ #4 Ví dụ SetCookie []setcookie[] example
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
6Chấm trong tên biến đến
Thông thường, PHP không làm thay đổi tên của các biến khi chúng được chuyển thành một tập lệnh. Tuy nhiên, cần lưu ý rằng dấu chấm [thời gian, dừng hoàn toàn] không phải là một ký tự hợp lệ trong tên biến PHP. Vì lý do, hãy nhìn vào nó:
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
7Bây giờ, những gì trình phân tích cú pháp nhìn thấy là một biến có tên $ varname, theo sau là toán tử nối chuỗi, theo sau là barestring [tức là chuỗi chưa được trích xuất không khớp với bất kỳ khóa nào đã biết hoặc từ dành riêng] 'ext'. Rõ ràng, điều này không có kết quả dự định.
Vì lý do này, điều quan trọng cần lưu ý là PHP sẽ tự động thay thế bất kỳ dấu chấm nào trong các tên biến đến với dấu gạch dưới.
Xác định các loại biến
Bởi vì PHP xác định các loại biến và chuyển đổi chúng [nói chung] khi cần thiết, không phải lúc nào cũng rõ ràng là loại nhất định nào là bất kỳ lúc nào. PHP bao gồm một số hàm tìm hiểu loại một biến nào là, chẳng hạn như: getType [], is_array [], is_float [], is_int [], is_object [] và is_string []. Xem thêm Chương về các loại.gettype[], is_array[], is_float[], is_int[], is_object[], and is_string[]. See also the chapter on Types.
HTTP là một giao thức văn bản, hầu hết, nếu không phải tất cả, nội dung đi kèm trong các mảng SuperGlobal, như $ _POST và $ _GET sẽ vẫn còn như chuỗi. PHP sẽ không cố gắng chuyển đổi các giá trị thành một loại cụ thể. Trong ví dụ dưới đây, $ _get ["var1"] sẽ chứa chuỗi "null" và $ _get ["var2"], chuỗi "123".
/index.php?var1=null&var2=123
Thay đổi
7.2.34, 7.3.23, 7.4.11 | Tên của cookie đến không còn được mã hóa URL vì lý do bảo mật. |
Ẩn danh ¶ ¶
14 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
8$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
9Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
17 năm trước
Name:1
Email:
Name:2
Email:
Name:3
Email:
Name:4
Email:
Name:5
Email:
Name:6
Email:
Name:7
Email:
Name:8
Email:
Name:90123456
Email:
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
17 năm trước
89Name:0
Email:
Ẩn danh ¶ ¶
14 năm trước
/index.php?var1=null&var2=1231
/index.php?var1=null&var2=1232
Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
17 năm trước
/index.php?var1=null&var2=1234
TMK-PHP tại Infeline Dot org ¶ ¶
19 năm trước
/index.php?var1=null&var2=1235
/index.php?var1=null&var2=1236
/index.php?var1=null&var2=1237
/index.php?var1=null&var2=1238
/index.php?var1=null&var2=1239
Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
14 năm trước
onchange
1
onchange
2
onchange
3
onchange
4
onchange
5
onchange
6
Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
17 năm trước
onchange
8
onchange
9
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
19 năm trước
onkeyup
1
onkeyup
2
onkeyup
3
onkeyup
4
Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
3 năm trước
onkeyup
6
onkeyup
7
Name:0
Email:
Lennynyktyk tại Yahoo Dot Com ¶ ¶
14 năm trước
onkeyup
9
0
1
2
3
4
Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
17 năm trước
6
7
8
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
17 năm trước
QUERY_STRING
0
QUERY_STRING
1
QUERY_STRING
2
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
14 năm trước
QUERY_STRING
4
QUERY_STRING
5
Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
17 năm trước
QUERY_STRING
7
QUERY_STRING
8
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
19 năm trước
//www.example.com/test.php?id=3
0
//www.example.com/test.php?id=3
1
//www.example.com/test.php?id=3
2
Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
17 năm trước
//www.example.com/test.php?id=3
4
//www.example.com/test.php?id=3
5
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
17 năm trước
//www.example.com/test.php?id=3
7
//www.example.com/test.php?id=3
8
//www.example.com/test.php?id=3
9
Name:0
Email:
TMK-PHP tại Infeline Dot org ¶ ¶
19 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
01$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
02$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
03$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
04$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
05$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
06$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
07$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
08$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
09Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
19 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
11$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
12$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
13$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
14Anisgazis tại Gmail Dot Com ¶ ¶
3 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
15$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
16Name:0
Email:
Lennynyktyk tại Yahoo Dot Com ¶ ¶
19 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
18$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
19$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
20Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
17 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
22$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
23$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
24$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
25$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
26TMK-PHP tại Infeline Dot org ¶ ¶
14 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
27$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
28$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
29$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
30$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
31Name:0
Email:
Krydprz tại IIT dot edu ¶ ¶
19 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
33$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
34$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
35$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
36$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
37$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
38$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
39Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
17 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
41$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
42Name:0
Email:
Anisgazis tại Gmail Dot Com ¶ ¶
5 năm trước
$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
44$[ document ].ready[function[] {
$['input[id="country"]'].on['keyup', function[] { // on keyup event in your input field
$["#needs"].append[this.value];// append values from input field
}];
];
45Name:0
Email: