Silvar Posted January 6, 2013 Share Posted January 6, 2013 (edited) 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 January 6, 2013 by Silvar Quote Link to comment https://forums.phpfreaks.com/topic/272772-jquery-click-function-doesnt-activate/ Share on other sites More sharing options...
Silvar Posted January 6, 2013 Author Share Posted January 6, 2013 (edited) Okay, I've fixed first problem. The $(function() { had to be ontop of everything. Now alert() works, that means the script is being extracted. But my variables aren't getting changed. Edited January 6, 2013 by Silvar Quote Link to comment https://forums.phpfreaks.com/topic/272772-jquery-click-function-doesnt-activate/#findComment-1403761 Share on other sites More sharing options...
haku Posted January 7, 2013 Share Posted January 7, 2013 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]') Quote Link to comment https://forums.phpfreaks.com/topic/272772-jquery-click-function-doesnt-activate/#findComment-1403808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.