SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript submit

    hey there-- i started learning javascript all of yesterday and i am having a hard time with this script i am writing. i want the links to open a particular page while submitting the form that will pass a hidden field. i keep getting the default page, however, not the page i want. here is my script (it is actually an html embedded in a perl script but this is just the former):

    <HTML>
    <HEAD><TITLE>Gaging Station Inventory Database</TITLE>
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript">

    <!--
    function SubmitForm(selectedPage)
    {
    document.autosubmit.page.value = selectedPage;
    document.autosubmit.submit();
    }

    function openPage(selectedPage)
    {
    switch(selectedPage) {
    case "retrieve":
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/retrieve.pl";
    break;
    case "docs":
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/docs.pl";
    break;
    case "update":
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/update.pl";
    break;
    case "pictures":
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/pictures.pl";
    break;
    case "home":
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/home.pl";
    break;
    default:
    window.location="http://oregon.usgs.gov/uo/safety/gagehouse/station_home.html";
    }
    }

    -->

    </SCRIPT>

    </HEAD>

    <BODY bgcolor="#004444" text="#cc6600" vlink="#cc6600" link="#cc6600" alink="#cc6600">

    <IMG alt="USGS: science for a changing world" WIDTH=478 HEIGHT=70
    SRC="http://oregon.usgs.gov/Imgs/Markup/gifs/usgs_banner.gif" frame=0>
    <BR>
    <BR>
    <BR>
    <TABLE border=0 cellpadding=25 width=100%>
    <TR><TD colspan=6 align=center valign=top width=15% bgcolor="#004444" text="#cc6600" vlink="#cc6600" link="cc6600">
    <H3>CONTENTS</H3><BR>

    <FORM NAME=autosubmit METHOD="post" ACTION=javascriptpenPage()>

    <INPUT TYPE="hidden" NAME="name" VALUE=$name{$FORM{'name'}}>
    <INPUT TYPE="hidden" NAME="page">

    <A HREF="javascript:SubmitForm('retrieve')">Retrieve Data</A><BR><BR>
    <A HREF="javascript:SubmitForm('docs')">View Safety Documents</A><BR><BR>
    <A HREF="javascript:SubmitForm('update')">Update Station Data</A><BR><BR>
    <A HREF="javascript:SubmitForm('pictures')">View Pictures</A><BR><BR>
    <A HREF="javascript:SubmitForm('home')">Site Home</A><BR><BR>
    <A HREF="http://oregon.usgs.gov/uo/safety/gagehouse/station_home.html">Change Site</A>
    </TD>
    <TD bgcolor="#cccc99" text="#003300" vlink="#dd9911" link="#0033aa" align=center cellspacing=100 cellpadding=200>

    $name{$FORM{'name'}}

    </FORM>
    </TD>
    </TABLE>
    </BODY>
    </HTML>

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <FORM NAME=autosubmit METHOD="post" ACTION=javascriptpenPage()>
    Try this

    Code:
    <form name="autosubmit" method="post" action="" onsubmit="openPage()">
    that will call the javascript code.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, that worked to call the function, but now for some reason i am getting an error page telling me that i am denied access, but to

    http://oregon.usgs.gov/cgi-bin/uo/gagehouse/

    it seems to be ignoring the filename at the end of the path

    any ideas what i am doing wrong?

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by sadielane
    thanks, that worked to call the function, but now for some reason i am getting an error page telling me that i am denied access, but to

    http://oregon.usgs.gov/cgi-bin/uo/gagehouse/

    it seems to be ignoring the filename at the end of the path

    any ideas what i am doing wrong?
    Is the original page on the same domain. Can you give me the linking page?..

    Otherwise for now I don't really know I need the originating page.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is the page for the script i posted:

    http://oregon.usgs.gov/cgi-bin/uo/gagehouse/gage_home.pl

    and here is the link i am trying to open:

    http://oregon.usgs.gov/cgi-bin/uo/gagehouse/retrieve.pl

    here is the error message i am getting:

    Access Denied
    The document you are requesting, 'http://oregon.usgs.gov/cgi-bin/up/gagehouse/', was not found on this server or you are not permitted access

    what i don't understand is why it is denying me access to NOT what i am requesting.

  6. #6
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if you just got rid of the javascript.

    <a href="http://oregon.usgs.gov/uo/safety/gagehouse/retrieve.pl"> Link </a>

    For example. There is no need for you to even have a form process there. You have 5 links that are simply linking to other pages. Just have 5 statements like the above instead of calling javascript.

    Sorry when I first looked at the code I thought you had a drop down menu. Unless you have a reason for using a form you don't need to use it...
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, i thought of that, but i don't know if you noticed that i am trying to pass a hidden field value to the page that i am opening, that's why i am using javascript to submit a form. do you know if it's possible to pass a hidden field without submitting a form?

  8. #8
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by sadielane
    yeah, i thought of that, but i don't know if you noticed that i am trying to pass a hidden field value to the page that i am opening, that's why i am using javascript to submit a form. do you know if it's possible to pass a hidden field without submitting a form?
    Yes I do...and yes I did notice...

    Can you use PHP. If so then I think I have a solution I just have to figure something out

    [edit]
    If you can use php try this

    Code:
    //this will send the variable along with the link. 
    <a href="test2.php4?totalname=<?= $fullname; ?>">test</a>
    If you aren't using php (can't) I think the idea behind moving variables around like that is similar but I couldn't help you because besides js and php/mysql I would be stuck sorry
    Last edited by Maelstrom; Nov 29, 2001 at 18:44.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


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
  •