LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2004, 01:07 PM   #1
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Rep: Reputation: 30
JavaScript & PHP


Hi Guys I would like some on help on this form.

Hi I have the following function and It currently doesnt ask me for fill the blank field TeamName, What could be wrong?

Thanks a lot.
PHP Code:

function GetUserPredictions($user$Team$Copa$Nombre,$Equipo,$NombreEquipo,$Division) {

    
$link OpenConnection();
    if (
$link == FALSE) {
      echo 
"Unable to connect to the dbase";
      return;
    }

    echo 
"<form action=\"Ingresar-Apuesta.php\" method=\"POST\">";
    echo 
"<td  class=\"TBLROWER\"><font class=\"TBLROW\">$datestr $timestr</font></td>";
    echo 
"<input type=\"text\" name=\"TeamName\" value=\"$NombreEquipo\" >";

    echo 
"<input type=\"submit\" onSubmit=\"checkEquipo(this.form);\"name=\"Submit\" value=\"Submit\"></td>";
    echo 
"</form>";

    <
SCRIPT LANGUAGE="JavaScript">
    function 
checkEquipo(form) {
    if (
form.TeamName.value == "") {
    
alert("Fill the form");
    return (
false);
    }
            return 
true;
    }
     
</SCRIPT> 

Last edited by Gerardoj; 06-10-2004 at 01:08 PM.
 
Old 06-11-2004, 01:02 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

There are a couple of problems here:
1. I'd declare the javascript function *before* I use it.
2. Since you're initializing the text value with "$NombreEquipo", it might not be blank
... but the real problem is ...
3. Your onSubmit() method needs to go in the *form* tag (not "input type=submit").
Code:
<script language="JavaScript">
  function checkEquipo (f) {
    if (f.TeamName.value == "" || f.TeamName.value == null) {
      alert ("value empty!");
    }
    else {
      alert ("value= " + f.TeamName.value);
      return (true);
    }
  }
</script>
<form method="POST" onSubmit="checkEquipo (this);">
<table border="0">
<tr>
  <td>#/Equip:</td>$NombreEquipo
  <td><input type="text" name="TeamName" value="0"></td></tr>
<tr>
  <td colspan="2">
  <input type="submit" name="Submit" value="Submit"></td></tr>
</table>
</form>
'Hope that helps .. PSM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP,JAVASCRIPT and CheckBox aznita Programming 2 06-17-2005 05:33 AM
Can I use PHP variables in javascript? nickiv Programming 1 06-07-2005 06:41 AM
Arrays, checkboxes in javascript & PHP Elijah Programming 21 11-16-2004 12:37 AM
PHP and JavaScript Gerardoj Programming 4 04-22-2004 03:02 PM
PHP and or Javascript Can they be used the same way? ElementNine Programming 1 03-05-2004 09:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration