Absolutely. I'm fairly certain you've already done so elsewhere.Pavilion wrote:Is it possible to construct a listener and reference an input ID or input name?
Code: Select all
$('#element_id').change(function() {
// blah blah blah
});Moderator: General Moderators
Absolutely. I'm fairly certain you've already done so elsewhere.Pavilion wrote:Is it possible to construct a listener and reference an input ID or input name?
Code: Select all
$('#element_id').change(function() {
// blah blah blah
});OK - but what is confusing me is this statementAbsolutely. I'm fairly certain you've already done so elsewhere.Pavilion wrote:Is it possible to construct a listener and reference an input ID or input name?
Code: Select all
$('#element_id').change(function() { // blah blah blah });
As a refresher, this checkbox is in a table. So... I can understand (if id's are suppose to be unique to a page) why (in a table situation id's shouldn't be used). But.... then how can I reference an element's id or name in a table situation? Or am I just misunderstanding your cautions about ID's and unique values within a page?Also, I noticed you still have id='chk_Bx' everywhere. This can lead to problems.
Code: Select all
$('input[name=whatever]').change(function() {
// do stuff
});OK - same problem, new twist:Celauran wrote:You reference IDs as specified above, whether they're part of a form, table, or otherwise. To access a form input by name, use something likeCode: Select all
$('input[name=whatever]').change(function() { // do stuff });
Code: Select all
<button type="button" class="button" name="send_csv">Send CSV</button>Code: Select all
$('input:button[name=send_csv]').click(function() {
alert("you found the listener");
});Code: Select all
$("button[name=send_csv]").click(function() {
var pass_file = document.addressbk_frm.file.value;
$('#demo').html(pass_file);
$.post("addressbk_data_1.php",{bind_file:pass_file},function(data){
$('#demo').html(data);
});
});Code: Select all
$.post("addressbk_data_1.php",{bind_file:pass_file},function(data){
$('#demo').html(data);
});Code: Select all
<?php
session_start();
// include database connection file, if connection doesn't work the include file will throw an error message
include '../tfm/include/db_connect.php';
// include data process file - contains custom functions.
include '../tfm/include/custom_functions.php';
// Define user_id and record date for INSERT and UPDATE Statements
$userid = $_SESSION['user_id'];
$firstcontact = date("Y-m-d");
/////////-------------testing here
$file = $_POST['bind_file'];
$_FILES["file"]["tmp_name"] = $_POST['bind_file'];
if (file_exists($file));
{
echo "files variable: " . $_FILES['file']['tmp_name'] . "<br />";
echo "file type: " . $_FILES['file']['type'] . "<br />";
}
///////////----------------End testing
?>Code: Select all
echo "files variable: " . $_FILES['file']['tmp_name'] . "<br />";Code: Select all
echo "file type: " . $_FILES['file']['type'] . "<br />";Thanks Celauran - but after reviewing the link you provided, I've decided to hold off. My current php page is working, I thought I could clean it up a bit. But, there are more important things for me to learn right now. Your help is truly appreciated though. You no idea how much I've learned.Celauran wrote:How can I upload files asynchronously with jQuery?
Here's the kicker - the form posts to the same page, and the url is the address of my php page.File not found. Make sure you specified the correct path.
Code: Select all
document.onkeypress=KeyPress;
function KeyPress(e)
{
var code =(window.event)? event.keyCode : e.which;
if(code==13) {alert('Enter key');}
}Is actually a message generated if the POST routines cannot find a CSV file uploaded by users. So... now that I know where the conflict is (and it is NOT acting this way in IE) - how do I get Firefox to stop "seeing" the ENTER key as a submit?File not found. Make sure you specified the correct path.
Code: Select all
$(whatever).keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
}
});Thanks - CelauranCelauran wrote:Code: Select all
$(whatever).keypress(function(e) { if (e.which == 13) { e.preventDefault(); } });
Code: Select all
<input class="a" tabindex="1" type="text" id='f_name' name='fname' onkeypress="prevent_default();"/>Code: Select all
prevent_default=function(e)
{
// alert("found it"); - this alert works
alert(e.which); // this alert does not pop up (what am I doing wrong)?
if (e.which == 13) {
e.preventDefault();
}
};Code: Select all
<input tabindex="1" type="text" id='f_name' name='fname' onkeypress='return prevent_default(this,event)'/>Code: Select all
function prevent_default(obj,e) {
var isfocus=0
if (isfocus==1) return
var key_stroke=(window.event)? event.keyCode : e.which;
var var_next = $(this).next(':input').name;
console.log("your key stroke is: ") + console.log(key_stroke);
if (key_stroke == 13) {
var ele = document.forms[0].elements;
for(var i=0;i<ele.length;i++){
var q=(i==ele.length-1)?0:i+1;// if last element : if any other
if(obj==ele[i]){ele[q].focus();break}
}
e.preventDefault();
}
}