Converting the output of alert into a string that i can send to another section of the program

How can i get the value alert(input) maybe into a string so i can work with the data… to send it to another file… I know the results of the alert are not a string… or is there a way i can ask for the answer with something other than an alert to get the name phone number and etc… so that i can use it in any way that i desire… Thanks

input = document.getElementById("form-firstname").value
alert(input)
input = document.getElementById("form-lastname").value
alert(input)
input = document.getElementById("form-email").value
alert(input)
input = document.getElementById("form-phone").value
alert(input)
input = document.getElementById("form-password").value
alert(input)

it is getting all the variable answers but i need them in a string like mode…

Are you maybe looking to use something like a prompt() instead of alert?

Check out the examples there and let us know if that is what you are wanting to do. I am not sure you even need either alert or prompt because you can use your form, get the value you like you are doing and your input variable is where the value is to work with. But let us know if you are wanting a prompt like I mention above. :slight_smile:

This would be perfect but its like apples and oranges… no match they need conversion before the output can be used as a variable… do you know how to convert:

$firstname = document.getElementById("form-firstname").value  (perfect but wont work)

No prompt. and you are right i don’t need the alert … The alert just lets me see that I have captured the correct values that I need… Now i just need to get them in a file on disk or string variable that i can use to send to the next step…
like this $data = “Jim|Johnston|jim@example.com|757-1232-4567|mypassword}”
or anything that puts it in a string so i can use it… readily…another example

$fname = "Jim"
$lname= "johnston"
$email = "jim@example.com

Basically convert that output into a string variable…

If you are collecting a firstname, it comes as a string. You don’t need to convert it (assuming that `form-firstname’ is a textbox element of the form).

However if you need to convert values, you always have parseInt and parseFloat etc. to parse and convert values.

Also, don’t use dollar signs in your JavaScript variable names.

But anyways, like I was saying, if you are reading from form elements, they ARE typically strings for standard textboxes etc.

Thank you that makes sense…
Are you saying that if I took this line

$firstname = document.getElementById("form-firstname").value  (perfect but wont work)
And removed the $ sign...
firstname = document.getElementById("form-firstname").value 

the firstname is still not a string corrct…how would I convert it so it could be used like a string.
like this.
$fname = firstname since its not really a string how do i convert so it is a string…
Thanks…
and could then save it like a string…<? file_contents_put("myfile.txt", $fname); ?>
Thanks