#1
  1. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22

    Javascript - document.form.submit doesnt work, Submit button does.


    Hey all, I have a rather odd problem.

    On a site i am working on we are running PHPBB (infact we are running two instances of PHPBB.

    What my goal is, is to have the user to be able to login to either BB from the home page.

    So what i have done is the following.

    I have a form with Username/ password field, then a drop down box so the user can select which BB to log into.

    because i couldnt work out a way of getting the <form action=""> to change depending on the selection in the drop down box i decided to have the page submit to a php page with the same from (only all fields are hidden) with the <form action=""> going to the variable from the selection box. The user then his submit again and it wizzes off to the right BB and logins in perfectly.

    The problem is that the user has to click twice to actually log in, so i though i could just add...

    Code:
    <SCRIPT LANGUAGE="JavaScript"><!--
    setTimeout("document.forms[0].submit()",3000);
    //--></SCRIPT>
    Only when it submits the data that way the BB returns a login error.

    I also found that if i have <form name=""> that the BB returns an error. So i just left the name part out.

    I'm not sure if this makes any sence but its a bit wierd.

    If anyone has any ideas it would be greatly appriciated. Infact a better way for me to do this would be able to have the form action change with the selection in the selection box!
    "The cause will equal the effect after the effect has preceded the cause"
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    <select onchange="this.form.action=this.options[this.selectedIndex].value">
    <option value="file1.php">BB 1</option>
    <option value="file2.php">BB 2</option>
    </select>
  4. #3
  5. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    Works a treat, Thankyou very much
    "The cause will equal the effect after the effect has preceded the cause"

IMN logo majestic logo threadwatch logo seochat tools logo