Jump to content

Recommended Posts

I've made this script. When i click the "#name_$gId" <div> where $gId is a unique id, it doesn't change any variables.

- I've tried debugging by putting in an "alert();" to see if anything gets activated at all, but it doesn't.

- I've looked up several places and the click function should written as it is.

- I've looked at the echoed sourcecode at my page with "show source" and the "#name_$gId" fits both in the script and at the <div> which should activate my script.

 

echo <<< END
<script type="text/javascript">
$("#name_$gId").click(function() {
$(function() {
$('[name=debtForm]').get('debtForm').setAttribute('action', 'scms_actions.php?id=$_GET[id]&what=debt&do=edit&which=$editWhich');
$('[name=debtName]').val('$gName');
$('[name=debtAmount]').val('$gAmount');

$('[name=withdrawDeposit]').attr('readonly', false);
$('[name=debtName]').attr('readonly', true);
});
});
</script>
END;

Edited by Silvar
Link to comment
https://forums.phpfreaks.com/topic/272772-jquery-click-function-doesnt-activate/
Share on other sites

A few comments:

 

1) It's best to only use alphanumeric characters, underscores and hyphens in your IDs. Consider it a best practice. You may find that it will work with $ signs like you are using but this may cause problems in various javascript libraries or browsers.

2) .get('debtForm') will look for an element of type <getForm>, which doesn't exist.

3) You are using the [] selector without specifying a type of element. Try changing $('[name=debtName]') to something like $('input[name=debtName]')

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.