SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    birmingham, uk
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why does my sumit button not work

    hey
    sorry people but I have a problem again! i dont know why the submit button in the form openindex dont work dont know why?


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Patient Record</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <SCRIPT LANGUAGE="JavaScript " type="text/Javascript">


    function C()
    {
    alert("hello");
    }


    function openindex(s)
    {

    //this function opens up the window
    //CREATES THE ARRAY AGAIN
    var s = s.split(",");
    //OPENS UP THE NEW WINDOW
    OpenWindow=window.open("", "newwin", "height=250,width=300," +
    "toolbar=yes,scrollbars=yes,menubar=no")

    OpenWindow.document.write("<FORM name=\"testform\" action=\"C()\" method=\"POST\">");OpenWindow.document.write ("<select name=\"testselect\">");

    for (i=0; i< s.length; i++)
    {

    OpenWindow.document.write("<option value=\"s[i]\">",s[i]," ",s[i=i+1]);

    }
    OpenWindow.document.write ("</select>");
    OpenWindow.document.write("<input type=\"submit\" value=\"hello\">");
    OpenWindow.document.write ("</FORM>");


    //OpenWindow.document.close();
    //self.name="main";

    }


    </SCRIPT>

    </head>

    <body>
    <?Php

    $Host = "localhost";
    $User = "root";
    $Password = "";
    $db= "MedicalCenter";
    $TableName ="pd";
    //link the database
    $Link = mysql_connect($Host,$User,$Password) or die("<H1>Error</H1><P>Could Not Connect To Database </FORM></BODY></HTML>"); ;
    mysql_select_db($db)or die("<H1>Error</H1><P>Could not select database </FORM></BODY></HTML>");
    //create a text box for the surname
    echo "<form method=\"POST\" action=\"P1.php\">";
    echo "<P><B>Surname : </B>
    <INPUT TYPE=TEXT NAME=\"P\" Size=35 value =\"$P\" >";

    if (chr(13))
    {
    print("hello");
    //search for all patients matchin the surname entered
    $sql = "SELECT * from pd where Surname LIKE '$P%'";
    $res = mysql_query($sql) or die (" $result Invalid query3");
    //get the number of rows found
    $num_rows = mysql_num_rows($res);
    $i=0;
    //if no matching results are found
    if($num_rows ==0)
    {
    print("<P>There are no patients matchin the surname you entered");
    }
    //put the values retrieved from the database into an array
    if ($num_rows > 0)
    {
    while ($row = mysql_fetch_array($res)){
    $PatientArray[$i]=$row[3];
    $i++;
    $PatientArray[$i]=$row[9];
    $i++;
    }
    print_r ($PatientArray);
    $comma_separated = implode(",", $PatientArray);
    print($comma_separated);

    //THIS ALLOWS ME TO CALL THE FUNCTION
    echo"<FORM >
    <INPUT type=\"submit\" value=\"...\" OnClick=\"openindex('$comma_separated')\">

    </FORM>";
    // *******************************************

    }
    }
    ?>

    </body>
    </html>


    I have also used:
    OpenWindow.document.write("<FORM name=\"testform\" action=\"javascript:C()\" method=\"POST\">");
    this has not worked either does anyone know why? I appreciate your help.

    humaira

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the javascript&#058; pseudo&#045;URL without the underscores, if you are using them in your code. The underscores are inserted by the forum program and shouldn't be part of your code. If you have that correctly done in your code, it should call the function, so something else is the problem.
    Last edited by JVLB; Jul 11, 2004 at 18:53.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Too much server-side code to evaluate this properly (or even determine exactly what you intended to do), but this:
    Code:
    <FORM name="testform" action="javascript&#58;C()">
    ...can't run, since the function C() is in the main window, and you're calling it from the pop-up. javascript&#58;opener.C() would probably execute the call; but there are more cosmetic ways of doing this entire thing. Would need an HTML page to demonstrate...
    ::: certified wild guess :::

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    birmingham, uk
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    I have tried calling the function using by inserting javascript:C() but that dont work either any more sugesstions????

  5. #5
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We need to see the actual HTML output of your PHP script. Something other than the function calling action is to blame for the failure.

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would probably help if you read people's answers.
    ::: certified wild guess :::

  7. #7
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bear in mind, adios, that for some English is not a primary language, so comprehension may lag behind reading. Sometimes a simple restatement can make all the difference.

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...so comprehension may lag behind reading.
    But apparently not condescension.

    It might have been less distracting if you hadn't repeated your faulty analysis of the problem as if a better diagnosis hadn't been made.
    Something other than the function calling action is to blame for the failure.
    ::: certified wild guess :::

  9. #9
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry if my attempts to clarify for humaira what I interpreted you to be saying were either off base or somehow offensive to you. That was not my intent.

    As to fault with my analysis, such analysis was reserved pending clarification. I have seen code with java_script_ in it due to people copying from forums like these. It often works, strangely enough, but would not in this instance.


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
  •