Javascript Werte in ASP link weitergeben?
dalia
- javascript
0 Frank
Hallo Forum,
Ich lade auf einer Seite images in einem div die ich danach repositioniere, ich moechte danach die x und y Werte in CommentsForm?asp Weiter geben.
aber Wie?
hier ist die positionierung function:
function PositionImage(nr)
{
// nr = number of pictures whithout logos
// I have to find out the nr of images which have the logo
// then I have to add the nr of logos to nr and skip the logos to repostioning
var j = 0;
var k = 0;
var nrpic = 0;
for (i = 0; i <= nr; i++)
{
var lenge = eval(document.images[i].src.length);
if (document.images[i].src.subString(lenge - 7,lenge) == 'can.jpg') //counts logo images from the total of images
{
k++;
}
}
var intnr = parseFloat(nr); // transforms a String into number
intnr += k; // adds the nr logos to the nr of pictures
// repositions the images
for (i = 0; i < intnr; i++)
{
var lenge = eval(document.images[i].src.length); //
var logoname = document.images[i].src.subString(lenge - 7,lenge); // extracts the logoname from src
if ( logoname != 'can.jpg') //exclude logo from repositioning
{
j++; // counts images <> form logo
rp = eval(document.images[i]);
if (document.myform["pozx"+i].value != '' && document.myform["pozy"+i].value != '' )
// if pox and poy is saved in Table Comments
{
rp.style.position = "absolute";
rp.style.top = document.myform["pozx"+i].value;
rp.style.left=document.myform["pozy"+i].value;
}
else
// loading and positioning images
{
if ( (j > 6) && ((j % 6 == 1) || (j % 6 == 2)))
{
// images positioned on a new page where the x-coordinate must be increased more
if ((i % 2) == 1) // left side images
{
rp.style.position = "absolute";
rp.style.top = 250 + x + 200;
rp.style.left = 20;
x = x + 290
}
if ((i % 2) == 0) // right side images
{
rp.style.position = "absolute";
rp.style.top = 250 + (x - 90);
rp.style.left = 520;
x = x + 90
}
}
else
{
//pictures on the same page
if ((i % 2) == 1) // left side images
{
rp.style.position = "absolute";
rp.style.top = 250 + x;
rp.style.left = 20;
}
if ((i % 2) == 0) // right side images
{
rp.style.position = "absolute";
rp.style.top = 250 + (x - 90);
rp.style.left = 520;
}
x = x + 90;
}
}
}
}
}
und hier ist ein Stueck des ASP code :
<%for nfile = 1 to filecount %>
<div id="<%=nfile%>"><a href="CommentsForm.asp?nPath=<%=sqlPath%>" target="Comments" onclick="window.open('','Comments','toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=720,height=370')"><IMG src="<%=relativPath & nameArray(nfile,1)%>" border="0" width="200"></div>
<%if not rsComments.eof then
if (not isNull(rsComments("pox")) or rsComments("pox") <> "") and (not isNull(rsComments("poy")) or rsComments("poy") <> "") then%>
<input type=hidden name="pozx<%=nfile%>" value="<%=rsComments("pox")%>">
<input type=hidden name="pozy<%=nfile%>" value="<%=rsComments("poy")%>">
<% end if
end if %>
<input type=hidden name="pozx<%=nfile%>" value="">
<input type=hidden name="pozy<%=nfile%>" value="">
<% next
for k = nfile to nfile + nrPages - 1%>
<input type=hidden name="pozx<%=k%>" value="">
<input type=hidden name="pozy<%=k%>" value="">
<%next%>
</form>
<script language = "Javascript"><!--
PositionImage('<%=filecount%>');
//-->
</script>
wie kann ich in <a herf CommentsFor,.asp?.....
die rp.style.top uebergen?
vielen Dank,
Dalia
Hi Dalia,
in dem du beim Abschicken des Formulares (onSubmit="deineJSFunktion();") heimlich, still und leise vorher leere hidden-inputs mit Werten füllst.
form['deinFormular'].elements['hiddenField'].value = 'dein Wert';
HTH, Frank