View Full Version : Dynamic div tag content?

02-03-2006, 06:15 PM
I am trying to generate an overlapping popup (using a script from DynamicDrive.com). The script works great, but my situation is this:

I have several links that each bring up a form for the user to complete. The form needs to have some hidden variables passed to it, and those depend on the link that is clicked.

Is there a way to pass variables from the link to the DIV tag so I don't need to create 12 different DIV tags to serve each individual link? I guess I'm asking: is it possible to have the DIV tag put in the correct variables (for the form) when the link is clicked?

Thank you!


02-03-2006, 09:14 PM
You can do something like so:

<a href="#" onclick="openDiv();return false">Link Text</a>

then have a function in a script block in the head:

function openDiv(){
var val1=document.getElementById('nameField').value;
var val2=document.getElementById('addressField').value;
var val3=document.getElementById('phoneField').value;
etc . . .
then code here to open the div and
code inserting the above values in its fields

But, this is better done with a server side language as, you cannot be certain folks will have javascript enabled.