Send variables to javascript(jquery) function -
I can not be able to send a variable in a JavaScript function when I click on the link, but for some reason I I can not find it anywhere on the Internet.
The function at the top of my page is:
& lt; Script & gt; Click (function () {$ ("# interfaceScreen"). Load ("module / interface / interfaceScreen.php? H = & Amp;; V = ");});}); & Lt; / Script & gt;
As you can see, I need the variable to keep after "h =" and "v =" parts.
Here is a link to activate the work in my page:
& Lt; / A & gt;
Where are the variables from? It is quite easy:
var h = 20; Var v = 40; Click (function () {$ ('[name = updateInterface]') Load ("Module / Interface / Interface. Screen.php? H =" + encodeurIComponent (h) $ ('(name = updateInterface)') (Function () {$ ("# interfaceScreen"). + "& Amp; v =" + enocdeurICompoennt (v));});});
Just make sure you escape from them.
You can of course get them from anywhere:
& lt; Input type = "text" id = "txth" & gt; & Lt; Input type = "text" id = "txth" & gt;
And then:
var h = $ ("# txth"). Val (); Var v = $ ("# txtv"). Val (); Edit: Edit: OK, you gather with your comments, send information from the server back to the customer so that the customer can send it back. The first time you have to handle your clicks in a non-jquery way: & lt; A href = "javascript: handle_click (17,43);" & Gt; Click me & lt; / A & gt; ; With
:
handle the function (click on h, v) {$ ("# interfaceScreen"). Load ("Module / Interface / Interface. Screen.php? H =" + EncoderIconant (H) + "& amp; V =" + EncoderRioOmMonnet (V)); }
This is probably the easiest solution if you want to be with jquery click handlers, you can always embed this information into an attribute or a hidden element. For example:
& lt; A href = "#" class = "special" & gt; & Lt; Div class = "special-h" & gt; 12 & lt; / Div & gt; & Lt; Div class = "special-v" & gt; 34 & lt; / Div & gt; Click me & lt; / A & gt;
With CSS:
a.special div {display: none; }
and:
$ (function () {$ ("a.special"). Click (function () {var h = $ ("Special-H"). Text (); $ ("# Interface Screen"). Load ("Module / Interface / Interface. Screen.HP? H =" + EncoderIconPaint (H) + "& V = "+ EncoderIconomnet (V));});});
There are several variations on this topic.
Finally, I suggest that I would advise you I'm not going to do the specialty finder selectors where you can avoid it. Give the class and / or id and use one of them to assign to the event handler. Also use a selector such as "a.special" on "special" (for performance reasons).
Comments
Post a Comment