Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Скажите, пожалуйста, почему не работает ?
Форумы портала PHP.SU » » Вопросы новичков » Скажите, пожалуйста, почему не работает ?

Страниц (1): [1]
 

1. Lagg - 26 Октября, 2017 - 11:48:00 - перейти к сообщению
Здравствуйте.

Есть код:
-------------------------------- -------------------------------- ----------------
<form name="Form" id="Form" onsubmit="return flag" method="get">
<pre>
Title: <input type="text" name="title" id="title">
RES:<input type="text" name="res" id="res">
<input type="submit" onclick="checkvalues();">
</pre>
</form>

<script>
var flag=false;

function checkvalues()
{
<?php if ($_GET["title"]=='3') echo 'flag=true;' ?>
}
</script>
-------------------------------- -------------------------------- ----------------

Почему не работает ?
Как можно сразу проверить значение и если равно 3 то отправлять данные ?
2. Vladimir Kheifets - 26 Октября, 2017 - 13:40:44 - перейти к сообщению
Lagg пишет:
Здравствуйте.

Есть код:
-------------------------------- -------------------------------- ----------------
<form name="Form" id="Form" onsubmit="return flag" method="get">
<pre>
Title: <input type="text" name="title" id="title">
RES:<input type="text" name="res" id="res">
<input type="submit" onclick="checkvalues();">
</pre>
</form>

<script>
var flag=false;

function checkvalues()
{
<?php if ($_GET["title"]=='3') echo 'flag=true;' ?>
}
</script>
-------------------------------- -------------------------------- ----------------

Почему не работает ?
Как можно сразу проверить значение и если равно 3 то отправлять данные ?

Добрый день! Не работает потому, что спутали PHP c JS
Должно быть:
CODE (html):
скопировать код в буфер обмена
  1. <script>
  2. function checkvalues()
  3. {
  4.         f=document.Form;
  5.         title=f.title.value;
  6.         if(title==3) f.submit();       
  7. }
  8. </script>
  9.  
  10. <form name="Form" id="Form" onsubmit="return flag" method="get">
  11. <pre>
  12. Title: <input type="text" name="title" id="title">
  13. RES:<input type="text" name="res" id="res">
  14. <input type="button" onclick="checkvalues();">
  15. </pre>
  16. </form>
3. Lagg - 26 Октября, 2017 - 15:43:44 - перейти к сообщению
Недавно начал программированием заниматься. В ООП пока плохо разбираюсь.
Спасибо ОГРОМНОЕ за помощь.

 

Powered by ExBB FM 1.0 RC1