Welcome to WebmasterWorld Guest from 18.204.48.199

Forum Moderators: open

Message Too Old, No Replies

Ajax - set variables with <a href

Is it possible?

     
7:20 pm on Jan 18, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Aug 29, 2003
posts:236
votes: 0


I have a working project using Ajax and I am having difficulties sending variables. I know how to do so if I'm using <form - but I am using just links (project requirment...) So, does anyone know how I can send/embed variables within an <a href statement?

Currently I am doing the following...which works... but doesn't send variable data:

<a href='/mylink' onClick="new generate_mask(['val1'], ['resultdiv']); return false;">

generate_mask is my Ajax defined function in my script.

Any idea how I can set val1 to a value?

10:37 pm on Jan 18, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts:5021
votes: 26



I know how to do so if I'm using <form - but I am using just links (project requirment...)

Uh... that's kind of a dumb project requirement. You can't even use hidden form fields? Also, it sounds like your application will not function at all if JavaScript is disabled... probably not a very good project design. You might want to start be re-evaluating the project requirements.

Is there any reason that you need to call generate_mask directly from the link? Could your link's onclick handler call some other JavaScript function which then calls generate_mask with the desired variables?