Jump to content
php.lv forumi

method=post action=javascript


future_funk

Recommended Posts

//index.php//

 

function load(url){window.open(url);}

 

<form method=post action="java script:load('register.php')">

<input name="lsubid" type=text>

<input type="image" src="button.gif" name="submit" width="38" height="15">

</form>

 

//dati.php//

<?php

echo $_POST[lsubid];

?php>

 

Probleema: netiek nosuutiiti dati no textboxa "lsubid" uz dati.php.

Iespeejams, ka javascript kaut ko maisa.. ja jaa, tad kaadaa veidaa vareetu panaakt, lai tomeer nostraadaa ar visu javascriptu ?

Link to comment
Share on other sites

easy:

  <script>
    function submitForm(form, url) {
      form.action = url;
      form.submit();
    }
  </script>
  ...
  <form method=post onsubmit="submitForm(this, 'register.php')">
    <input name="lsubid" type="text" />
    <input type="image" src="button.gif" name="submit" width="38" height="15" />
  </form>

Link to comment
Share on other sites

vai arī, ja tiešām vajag jaunā logā (kautgan tas bišķi tizli ir), tad:

  <script>
   function submitForm(url) {
     var lsubid = document.getElementById('lsubid').value; 
     window.open(url+'?lsubid='+lsubid);
     return false;
   }
 </script>
 ...
 <form onsubmit="return submitForm('register.php')">
   <input id="lsubid" type="text" />
   <input type="image" src="button.gif" name="submit" width="38" height="15" />
 </form>

Link to comment
Share on other sites

no w3.org:

<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
<!ATTLIST FORM
 %attrs;                              -- %coreattrs, %i18n, %events --
 action      %URI;          #REQUIRED -- server-side form handler --
 method      (GET|POST)     GET       -- HTTP method used to submit the form--
 enctype     %ContentType;  "application/x-www-form-urlencoded"
 accept      %ContentTypes; #IMPLIED  -- list of MIME types for file upload --
 name        CDATA          #IMPLIED  -- name of form for scripting --
 onsubmit    %Script;       #IMPLIED  -- the form was submitted --
 onreset     %Script;       #IMPLIED  -- the form was reset --
 accept-charset %Charsets;  #IMPLIED  -- list of supported charsets --
 >

Link to comment
Share on other sites

Nja, tiešām:

By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements. The target attribute may be set for elements that create links (A, LINK), image maps (AREA), and forms (FORM).

Link to comment
Share on other sites

×
×
  • Create New...