SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    communicating between pages

    First:

    I've one page (main.htm) that has various links and which one goes to a different page.

    Because all pages have an equal top frame, there is a code that catches a variable in each link (from the main.html) and if the var is 'a' it goes to 'a' page.
    (I think I'm not explaining very well)... Here is the code:

    Code:
    <script language="JavaScript">
    
    	function saltar(nome)
    	{
    		document.formgeral.nome.value=nome;
    		document.formgeral.submit();
    	}
    
    </script>
    Code:
    <form action="linkagem.htm" method=post name=formgeral>
         
                  <a href="javascript:saltar('destaque');"><img src="destaque.gif" width="112" height="24" border="0" alt=": destaque" a> 
    </form>
    In the linkagem.htm I have this code:

    Code:
    <html>
    <head>
    <title> :</title>
    <script language=JavaScript>
    if Request.Form("nome") = "destaque" then tx = "destaque.htm"
    if Request.Form("nome") = "desktop" then tx = "desktop.htm"
    if Request.Form("nome") = "contacto" then tx = "contacto.htm"
    if Request.Form("nome") = "voces" then tx = "voces.htm"
    if Request.Form("nome") = "encomenda" then tx = "encomenda.htm"
    if Request.Form("nome") = "publicidade" then tx = "pub.htm" 
    if Request.Form("nome") = "receita" then tx = "receita.htm" 
    </script>
    </head>
    
    <frameset rows="100,*" frameborder="NO" border="0" framespacing="0"> 
      <frameset frameborder="NO" border="0" framespacing="0" cols="*"> 
      <frame name="mainFrame" marginWidth=0 marginHeight=0 src="framesuperior.htm" frameborder="NO" scrolling="NO" noresize >
      </frameset>
      <frameset frameborder="NO" border="0" framespacing="0" cols="*"> 
      <frame name="action" scrolling="AUTO" <script language="JavaScript" src="tx"> </script> frameborder="no"> </frameset>
    </frameset>
    <noframes> 
    <body bgcolor="#196CA3" text="#000000">
    </body>
    </noframes></html>
    I think I can't use the if Request.Form in Java Script.
    This was working in ASP. But now I have to do it in Java S.

    Any help?
    I hope u could understand this.
    Last edited by magi; Aug 28, 2002 at 06:26.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, first of all, the javascript needs to be attached to the page with the form, and not the frameset. Second, no, Request.Form won't work in Javascript (that's an ASP-only thing) However, I believe I can duplicate what you are needing
    Code:
    <script>
    function doAction(nome) {
    document.forms['formgeral'].action = nome + '.htm';
    document.forms['formgeral'].submit();
    }
    </script>
    
    <form action="" method="post" name="formgeral">
    <a href="javascript:doAction('destaque');">
    <img src="destaque.gif" width="112" height="24" border="0" alt=": destaque">
    </a>
    </form>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by beetle
    Well, first of all, the javascript needs to be attached to the page with the form, and not the frameset. Second, no, Request.Form won't work in Javascript (that's an ASP-only thing) However, I believe I can duplicate what you are needing
    Code:
    <script>
    function doAction(nome) {
    document.forms['formgeral'].action = nome + '.htm';
    document.forms['formgeral'].submit();
    }
    </script>
    
    <form action="" method="post" name="formgeral">
    <a href="javascript:doAction('destaque');">
    <img src="destaque.gif" width="112" height="24" border="0" alt=": destaque">
    </a>
    </form>

    OK. It makes sense. But that code doesn't do what I'm looking for.
    The code on 'main.html' is correct and it works fine.

    Suppose I've five links that goes to five different pages. Each page has two framesets. The top frameset is equal to each page.
    I'm looking for a way that allows only a frame with the static top frameset and a bottom frameset that is 'empty' until nome is with a value. If the value is destaque the bottom frameset is replace by the destaque.htm. The top frameset and the bottom-empty frameset are the linkagem.htm.


    Code:
    <script language="JavaScript">
    
    	function saltar(nome)
    	{
    		document.formgeral.nome.value=nome;
    		document.formgeral.submit();
    	}
    </script>

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see. Well, first of all, javascript can't access POSTDATA. The form needs to use GET as it's method. Next, you will need my parseGetVars() function
    Code:
    function parseGetVars() {
    	var getVars = new Array();
    	var qString = unescape(top.location.search.substring(1));
    	var pairs = qString.split(/\&/);
    	for (var i in pairs) {
    		var nameVal = pairs[i].split(/\=/);
    		getVars[nameVal[0]] = nameVal[1];
    		}	
    	return getVars;
    	}
    Now, we can't include scripting in the middle of HTML objects like you tried to in your first post. Instead we need to write framset with javascript, and insert our variables where needed.
    Code:
    <html>
    <head>
    <title> :</title>
    <script language="JavaScript">
    function parseGetVars() {
    	var getVars = new Array();
    	var qString = unescape(top.location.search.substring(1));
    	var pairs = qString.split(/\&/);
    	for (var i in pairs) {
    		var nameVal = pairs[i].split(/\=/);
    		getVars[nameVal[0]] = nameVal[1];
    		}	
    	return getVars;
    	}
    var g = parseGetVars();
    </script>
    </head>
    
    <script>
    with (document) {
    	writeln('<frameset rows="100,*" frameborder="NO" border="0" framespacing="0">');
    	writeln('<frame name="mainFrame" marginWidth=0 marginHeight=0 src="framesuperior.htm" frameborder="NO" scrolling="NO" noresize >');
    	writeln('<frame name="action" scrolling="AUTO" frameborder="no" src="'+g['nome']+'">');
    	writeln('</frameset>');
    	}
    </script>
    
    <noframes> 
    <body bgcolor="#196CA3" text="#000000">
    </body>
    </noframes></html>
    Also, you can see that I removed the extraneous framesets, because they really didn't need to be there. You can put them back if you like. If you have to use POST for your form's method, let me know, there's a way to avoid using GET.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beetle: I'm going to check that. Thank u.

  6. #6
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well! It works.... it goes to the page. But the bottom one doesnt' appear. This is the URL Adress that appears in all: http://maga/biblia/linkagem.htm?nome...d=mailing+list



    I was trying to solve alone but I can't.

  7. #7
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That link doesn't work. What is the domain? You just put http://maga/

    maga.com?
    maga.net?
    maga.????
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  8. #8
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    That's on my computer. I'ven't the site on the web. I work with the Internet Service Manager that's why it appears http://maga.... (I think )

  9. #9
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it would be a big help to me if you could post it online so I could have a looksie.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  10. #10
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check your mail in the next minute. I send it to the one on your web site.
    Last edited by magi; Aug 28, 2002 at 10:03.

  11. #11
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK.

    Open the site on Front Page and navigating on it I've notice that when I click, for example, on link A it appears on the bottom page (of linkagem.htm) the paste call 'A'. This paste is on the same root of the site. Suppose I click on link call B it shows me the paste with the same name.

    So I did something like this in linkagem.htm...but it doesn't solve none:

    Code:
    writeln('<frame name="action" scrolling="AUTO" frameborder="no" src="'+g['nome'+'.htm']+'">');
    It's strange. Where come this adress: ?nome=destaque&edicoes=%5B+B%EDblias+%5D&textfield=mailing+list
    Last edited by magi; Aug 29, 2002 at 04:56.

  12. #12
    SitePoint Evangelist
    Join Date
    Jan 2001
    Location
    earth
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is solved.

    Code:
    <a href="javascript:doAction('destaque.htm');">


Bookmarks

Posting Permissions

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