Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 17:25 Der er 10 kommentarer og
1 løsning

opener.document.form1.value = + onClick

I en popup side som viser et søgeresultat, vil jeg gerne have overført en værdi til et text felt i opener.
Jeg har fusket flg. funktion sammen (ud fra bl.a. olebole's tidl. svar):

function selectImage(val) {
    op = window.opener.document.form1;
    op.<%=request("who")%>.value = val;
    self.close();
}

I den tabel som viser billederne som brugeren kan vælge har jeg flg. href:
<a href='#' onClick="selectImage('/files/0000000299.jpg');"><IMG HEIGHT='100' SRC='<osv>..>

Men der sker ikke en skid når jeg klikker på et billede.

mvh
E1
Avatar billede Slettet bruger
23. oktober 2002 - 17:29 #1
Smid et link. Jeg kan ikke se nogen fejl.
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 17:30 #2
Det kan jeg ikke lige umiddelbart, ligger bag en fw. Kan jeg smide kilden istedet ?
Avatar billede Slettet bruger
23. oktober 2002 - 17:35 #3
Ja, det kan du vel, men hvorfor ikke bare uploade det på fx friserverplads?
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 17:37 #4
Uha, igennem alt det med at oprette o.s.v. Det er nu også fordi at de tabeller den tilgår kun kan tilgås fra den her maskine.

Her we go: det her er opener:

<html>
<head>
<title>Rediger artikel ..:: Mr Deeds - fra bondeknold til mangemillionær ::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/bbst.css" type="text/css">
<script language="JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  newwin = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
  newwin.focus;
}
//-->
</script>
</head>

<body bgcolor="#FDF9F4" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../images/menu_main_Ho_on.gif')">
<div id="ramme" style="position:absolute; left:164px; top:53px; width:460px; z-index:4">
  <table width="460" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><img src="images/join_ramme_midt.jpg" width="460" height="220"></td>
    </tr>
  </table>
</div>
<div id="txt" style="position:absolute; left:178px; top:81px; width:435px; height:116px; z-index:6">
  <table width="435" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="main" valign="top">
        <p><b>UPLOAD BILLEDE</b><br>
        </p>
        </td>
    </tr>
    <tr>
      <td class="main" height="20">
        <form name="form1" method="post" action="collectArticleWFiles.asp">
          <table width="435" border="0" cellspacing="0" cellpadding="4">
            <tr>
              <td height="10" width="10">&nbsp;</td>
              <td height="10">&nbsp;</td>
              <td height="10">&nbsp;</td>
            </tr>
            <tr>
              <td width="10" valign="top">&nbsp;</td>
              <td width="150" valign="top">
                <p>Upload billede til brug p&aring; forside og ved artikel visning.
                  Skal have formatet 200x125px.:
                  <i>Husk en sigende titel, helst med størrelsen.</i></p>
              </td>
              <td valign="top" class="main">
                <p>Titel:<br>
                  <input type="text" name="ForsideTitle" style="width:250px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
                  <input type="file" name="forsideBillede" style="width:250px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
               
              </td>
            </tr>
            <tr>
              <td width="10" valign="top">&nbsp;</td>
              <td width="150" valign="top">
                <p>Du kan ogs&aring; v&aelig;lge et eksisterende billede.</p>
              </td>
              <td valign="top" class="main"> V&aelig;lg eksisterende foto:<br>
                <input type="text" name="foto1" style="width:100px;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96" value="">
                <input type="button" name="eksistBilled" onClick="MM_openBrWindow('popupB2.asp?who=foto1','popBilledeForside','','650','725','true')" Value="V&aelig;lg">
              </td>
            </tr>
            <tr>
              <td height="10" width="10">&nbsp;</td>
              <td height="10">&nbsp;</td>
              <td height="10">&nbsp;</td>
            </tr>
            <tr>
              <td width="10" valign="top">&nbsp;</td>
              <td width="150" valign="top">
                <p>Upload billede til artikel visning ved kategori. Skal have
                  formatet 95x70px.:
                  <i>Husk en sigende titel, helst med størrelsen.</i></p>
              </td>
              <td valign="top" class="main">
                <p>Titel:<br>
                  <input type="text" name="kategoriTitel" style="width:250px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
                  <input type="file" name="kategoriBillede" style="width:250px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
              </td>
            </tr>
            <tr>
              <td width="10" valign="top">&nbsp;</td>
              <td width="150" valign="top">
                <p>Du kan ogs&aring; v&aelig;lge et eksisterende billede.</p>
              </td>
              <td valign="top" class="main"> V&aelig;lg eksisterende foto:<br>
                <input type="text" name="foto2" style="width:100px;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96" value="">
                <input type="button" name="eksistBilled2" onClick="MM_openBrWindow('popupB2.asp?who=foto2','popBilledeForside','','650','725','true')" value="V&aelig;lg"></td>
            </tr>
            <tr>
              <td width="10">&nbsp;</td>
              <td colspan="2">
                <input type="reset" name="Reset" value="Reset" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
                <input type="submit" name="submit" value="N&aelig;ste" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
              </td>
            </tr>
            <tr>
              <td width="10">&nbsp;</td>
              <td colspan="2" height="20">&nbsp;</td>
            </tr>
          </table>
        </form>
      </td>
    </tr>
  </table>
</div>
<div id="menu" style="position:absolute; left:180px; top:38px; width:435px; z-index:8">
  <table width="435" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td> <a href="article1.asp" onFocus="if(this.blur)this.blur()"><img src="images/menu_01_of.gif" width=113 height=18 alt="" border="0" name="Image0" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image0','','images/menu_01_over.gif',1)"></a></td>
      <td> <a href="java script:;" onFocus="if(this.blur)this.blur()"><img src="images/menu_02_on.gif" width=113 height=18 alt="" border="0" name="Image1" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','images/menu_02_over.gif',1)"></a></td>
      <td> <a href="java script:;" onFocus="if(this.blur)this.blur()"><img src="images/menu_03_of.gif" width=50 height=18 alt="" border="0" name="Image2" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','images/menu_03_over.gif',1)"></a></td>
      <td> <a href="java script:;" onFocus="if(this.blur)this.blur()"><img src="images/menu_04_of.gif" width=86 height=18 alt="" border="0" name="Image3" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/menu_04_over.gif',1)"></a></td>
      <td> <a href="java script:;" onFocus="if(this.blur)this.blur()"><img src="images/menu_05_of.gif" width=77 height=18 alt="" border="0" name="Image4" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','images/menu_05_over.gif',1)"></a></td>
    </tr>
  </table>
</div>
<div id="Layer1" style="position:absolute; left:13px; top:8px; width:151px; height:25px; z-index:7">
  <table width="250" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="main"><a href="index.asp" onFocus="if(this.blur)this.blur()">Tilbage
        til hovedmenu</a></td>
    </tr>
  </table>
</div>
</body>
</html>

Og her kommer popup:

<html>
<head>
<title>S&oslash;g billede BBST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/bbst.css" type="text/css">
<script language="JavaScript">
<
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function selectImage(val) {
    op = window.opener.document.form1;
    op.foto1.value = esc(val);
    self.close();
}
// -->


</script>
</head>

<body bgcolor="#FDF9F4" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">
      <table width="500" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="main" valign="top" height="5">&nbsp;</td>
        </tr>
        <tr>
          <td class="main" valign="top">
            <p><b>S&Oslash;G BILLEDE</b><br>
            </p>
          </td>
        </tr>
        <tr>
          <td class="main" height="20">
            <table width="500" border="0" cellspacing="0" cellpadding="4">
            <form name="form1" method="post" action="popupB2.asp">
            <input type="hidden" name="who" value="foto1">
                <tr>
                <td width="10" valign="top">&nbsp;</td>
                <td width="150" valign="top">
                  <p>S&oslash;g billede:</p>
                </td>
                <td valign="top" class="main">
                  <input type="text" name="search" value="12" style="width:150px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
                  <input type="submit" name="browse_billede" value="S&oslash;g" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;background-color: #FFEB96">
                </td>
              </tr>
              <tr>
                <td width="10" valign="top">&nbsp;</td>
                <td colspan="2" valign="top">
                  <table width="100%" border="0" cellspacing="3" cellpadding="0">                   
                   
                    <tr class="main">
                      <td colspan=4>Der vises max 15 ud af 242 billeder. Prøv at indtaste et mere præcist søgenavn.</td>
                    </tr>
                    <tr><td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002452.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002452.jpg' ALT='abernes-planet-200x125-blåhillel' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2452</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000001202.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000001202.jpg' ALT='Abernes_Planet_Ari_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>1202</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000003304.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000003304.jpg' ALT='aboutaboy200.125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>3304</TD></TR></TABLE></td>
</tr><tr><td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000001320.gif');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000001320.gif' ALT='ACDSee_200x125.gif' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>1320</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000000299.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000000299.jpg' ALT='Adam_Sandler_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>299</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002364.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002364.jpg' ALT='Afrika_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2364</TD></TR></TABLE></td>
</tr><tr><td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002858.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002858.jpg' ALT='Aki_Ross_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2858</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002860.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002860.jpg' ALT='Aki_Ross_eye_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2860</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002872.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002872.jpg' ALT='Aki_Ross_fra_siden_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2872</TD></TR></TABLE></td>
</tr><tr><td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002873.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002873.jpg' ALT='Aki_Ross_lips_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2873</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000000417.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000000417.jpg' ALT='Alice (GAME) 200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>417</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000000093.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000000093.jpg' ALT='Ally McBeal 200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>93</TD></TR></TABLE></td>
</tr><tr><td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000001468.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000001468.jpg' ALT='Ally_Sheedy_smiler_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>1468</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000002211.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000002211.jpg' ALT='Amanda_Ooms_200x125.jpg' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>2211</TD></TR></TABLE></td>
<td bgcolor='#888888' height='100' width='25%'><table border='0' cellpadding='2' cellspacing='1' width='100%' height='100%'><TR><TD align='center'><a href='#' onClick="selectImage('/files/0000000961.jpg');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000000961.jpg' ALT='Amerikansk_flag_200x125' BORDER='0'></a></TD></TR><TR><TD align='center' class='main'>961</TD></TR></TABLE></td>
</tr>
                  </table>
                </td>
              </tr>
              <tr>
                <td width="10" valign="top">&nbsp;</td>
                <td width="150" valign="top" class="main">&nbsp;</td>
                <td valign="top" class="main">&nbsp; </td>
              </tr>
              </form>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

vhE1
Avatar billede Slettet bruger
23. oktober 2002 - 17:44 #5
Prøv lige at ændre funktionen til dette:

function selectImage(val) {
    alert(val);
    op = window.opener.document.form1;
    alert(op.foto1.value);
    op.foto1.value = esc(val);
    self.close();
}

... og fortæl mig så, hvad der sker.
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 17:45 #6
Hmm, der sker nada, zip , nothing, intet!?

Så man kunne forestille sig at det er min onClick ?
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 18:10 #7
Hmm, jer har erstattet den lange '/files/...' med '12' og det virker STADIG ikke ??
Avatar billede Slettet bruger
23. oktober 2002 - 18:11 #8
Prøv dette:

<a href='#' onClick="alert('bla');"><IMG HEIGHT='100' SRC='http://bbst.koalit.com/files/0000001468.jpg' ALT='Ally_Sheedy_smiler_200x125' BORDER='0'></a>

Hvis der ikke dukker en alert op nu, så ved vi, hvad der er galt! :)
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 18:14 #9
Tja den kommer fint nok op?!
Avatar billede eksperten1 Nybegynder
23. oktober 2002 - 23:41 #10
Jeg store spasser....

Nu fik jeg den til at virke:
function selectImage(val) {
    opener.document.form1.<%=request("who")%>.value = val;
    self.close();
}

Det primære problem var vist at der lige efter <script...> taget kom en ensom < på en linje, den ødelagde hele scriptet.

SUCKS BIG TIME

Nå men nu kører det 1000 tak for hjælpen. :-)

vhE1
Avatar billede Slettet bruger
24. oktober 2002 - 17:58 #11
Nårh jo; den så jeg heller ikke!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester