Thursday, November 22, 2018

how to take a Value from a javascript variable, to be used as a php input variable via a button, without or not a submit button?

how to take a Value from a javascript variable, to be used as a php input variable via a button, not a submit button because the submit button cannot generate sequences more than once at the same time? I have tried this method but I still can't get the output ("x") from js using the button. this is my first code with javascript I tried as best I could because I tried to use break but it didn't work then i put x-- to freze it.





this javascript work like i want, but still can't get value "x" from button value




Code:



Test-2019










$a = array("str1", "str2", "str3", "str4", "str5");

if (isset($_POST['soal']))
{
$va = $_POST['soal'];
print $a[$va];
}
?>


on delphi I always use this method and I also tried to implement it but it didn't work so I tried making it with java script.




Delphi Example Code:



//global var
const
a : array[0..4] of string = ('str1', 'str2', 'str3', 'str4', 'str5');
var
g : integer;
...
...
//on create

g := 0;
...
...
//on button click
g := g + 1;
if g = 5 then
g = 0;
edit1.text := IntToStr(g);

//or like this example 2

button1.tag := button1.tag + 1;
if button1.tag = 5 then
button1.tag := 0;
edit1.text := IntToStr(button1.tag);


php code was i tried, like this



function fNext();
{

$x = 0;
if ($x == 5)
{
break;
}
x += 1;
}


i'm sorry if i included pascal/delphi code, cz maybe you can help me to convert it into php.




Thank you.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...