Results 1 to 6 of 6

Thread: Javascript :-(

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Angry

    Hello,

    I have some ASP code which reads thru a table and gets info from it like name, html etc.

    This info is used to build a table in HTML which displays the NAME and if there is a link to a webpage it adds the hyperlink which I get from the HTML fields in my db.

    This is how I do it... (not all the code...)

    html = rs("html")
    response.write "<tr><td width='33%'><p><font face='Arial'size='2'><a href=" & link2 & ">" & rs("name") & "</a></font><br></td>"

    link2 = "Javascript:windowOpen2()"
    this is a reference to a javascript function

    This function looks like this...
    <script language="JavaScript">
    <!--
    function windowOpen2()
    { window.open('<%=html%>',"NewWindow","width=500,height=320,noresize=yes,scrollbars=no,toolbar=0,menub ar=0");
    }
    // end popup windows -->
    </script>

    html in this function is the HTML field read from my db.

    My problem is.... how can I change link2 to have the HTML included in it. In other words, I want to pass the field HTML to my function. So link2 must look something like

    link2 = "Javascript:windowOpen2(),"<%html%>" (I've got no clue how the code should look like - just trying to demonstrate what I mean)

    To explain a bit more...
    There can be many "NAMES" which have webpages(HTML from my db) attached to it. I want the user to be able to click on a specific name and the corresponding webpage will open in a new window. What happens now is that all names show the SAME WEBPAGE, because right at the top (check my code) I set html = rs("html"). Thats why I need to know how to change "link2" (as example above) so that each and every NAME displayed on my page will have an unique "link2".

    This was NOT easy to explain - I hope you see what I'm getting at.

    Thanks,
    T





  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    link2 = "Javascript:windowOpen2(),"<%=html%>"
    this should work, did you try it!

    or put

    <a href="<%=yourHTMLPath%>">This is a link</a>

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343
    Jip, I tried it and it does not want to work!!

    The reason why I want to open the new window (maybe stupid) using the javascript function is because I can then set things like noresize,scrollbars=no,toolbar=0,menubar=0 etc etc.

    The main thing I want to be able to do is set the size of the window!!

    Can I do this using your second example....
    <a href="<%=yourHTMLPath%>">This is a link</a>

    I know to open the page in a new window you set the target="blank". How do I set the size,scollbars etc??

    If I can determine the size, hide scrollbars etc then I will be able to go for your second suggestion.

    Thanks,
    T

  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    ok do:

    <a href="javascript:myFunction();">this is a link</a>

    and in your function:

    function myFunction(){
    newWin = window.open("your page","_blank","width=350,height=150,menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbar s=0");
    if (newWin.opener == null) newWin.opener = self;

    but if you need more function,write it in asp:

    response.write "<script languiage=javascript>"
    response.write "function " & yourName
    .....
    response.write "</script"

    do it for all so in your link:
    <a href="javascript:<%=yourFirstNameFunction%>;">this is a link</a>

    do you know what i am saying,i hope i did'nt lost you!




  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Why not pass the URL to the function and make it generic?
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343
    Sounds good monte96,

    Can you give me some example code please??

    T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width