0

I have this form

<form action="<?php echo $response ?>?nexturl=<?php echo $nexturl ?>"
 method="post" enctype="multipart/form-data" onsubmit="return saveFile(); ">
 <input id = "file" name="file" type="file" style="border:none;"/>

I would like to do something like this:

return $action = saveFile();

I want to store the return value of saveFile() Which is a JavaScript code that returns a boolean into a PHP variable. How can I do this?

1 Answer 1

1

Preserve the value in hidden input field and then submit the form: Like this:

function saveFile()
{
    var val=true;
    var input=document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", "booleanValue");
    input.setAttribute("value", val);
    document.getElementById("form").appendChild(input);
}

To retrieve this value in php:

$myBoolean=$_REQUEST['booleanValue'];
Sign up to request clarification or add additional context in comments.

1 Comment

Can you show how I would call the created element from php?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.