Hi guys, I'm trying to figure out how to parse results from one form into another form. I never learned php or javascript while in school, so I'm trying to learn it now.
Specifically, what I am trying to do right now is display a list of checkboxes via html5 for the user to select, and then based on what the user selects, have that fill into another form via a string. I don't know if I should do this using php or if I could do it just using javascript. I'm not really trying to upload to a database as far as I know, but that is something that I should learn as well.
So for checkbox:
Apple = checked
Orange
Mango = checked
New Form
Fruit Selected:
Apple
Mango
My html code:
Here is a picture of what it looks like:
Again, I want the value of what is actually checked to display in a new page/form.
Thanks and sorry if I am not clear!
Latest PSU headlines:
Results 1 to 8 of 8
Thread: I need help with javascript/php!
-
05-25-2012 #1
I need help with javascript/php!
-
05-25-2012 #2Forum Guru







- Join Date
- May 2008
- Location
- Vilano Beach, FL
- Posts
- 3,867
- Rep Power
- 62
- Points
- 17,992 (0 Banked)
You mentioned PHP, so I’m assuming you’re on a server running PHP and your dev environment is ready to go!
Basically, web apps send data between pages by the URL/Querystring which you’ll see as some_page.php?key=value (which can be done using the form method GET, or manually constructing the query string, etc.), or by a POST (like your current FORM).
Then the “receiving” page just needs to access those values. In PHP, this is done through the $_GET[] and $_POST[] variables.
If you POST your form, you’ll need to indicate the page that will handle the POST processing, so let’s say the page you posted is form_main.php (or .htm since it doesn’t actually contain any server script). You’ll just want to change the FORM section to something like this:
Last edited by [DT]; 05-25-2012 at 14:33.
"Remember, you're young only once but you can be immature forever."
-
ex nihilo7 thinks this post is the dogs danglies.
-
05-25-2012 #3
Dude...Sweet! Thanks! I'm going to try this right now!
Yep, that was another thing I wasn't sure of.The Checkbox doesn’t “exist” in the POST unless it’s checked
edit: I got the non-array examples to work! It took me about 10 minutes to realize I was trying to run the form outside of my localhost server. I was like "why is echo not working!"
I'm going to try the array next.
edit2: I got the array working correctly! The only error is that when I don't select anything in the array, it gives me an error saying "undefined index". It must not know how to handle 0 selections.
here is a screenshot of it:
Last edited by ex nihilo7; 05-25-2012 at 22:38.
-
06-25-2012 #4
[DT] or anyone else, do you know how to strip the html from a php array on the fly for use when sending an html email?
I need to basically strip out the html somehow and email it at the same time.PHP Code:$N = count($ends);
echo ('<table border="1" class="lines" width="100%">');
echo ("<tr><th>Look For</th>");
echo ("<th>Observed Comments</th></tr>");
for($i=0; $i < $N; $i++)
{
echo("<tr><td width='50%'>");
echo($ends[$i] . "<p>");
echo("</td><td width='50%'>");
echo (" ");
echo("</td></tr>");
}
echo ('<table>');
echo ("<p>");
}
-
06-25-2012 #5Forum Guru







- Join Date
- May 2008
- Location
- Vilano Beach, FL
- Posts
- 3,867
- Rep Power
- 62
- Points
- 17,992 (0 Banked)
Yep, there’s a function built right into PHP:
strip_tags($string)
returns a string with the tags removed ($string is the input string).
So like:
$str = 'this is some markup
';
echo strip_tags($str);
Results in:
this is some markup
"Remember, you're young only once but you can be immature forever."
-
06-25-2012 #6
Thanks for the reply! I can't seem to get it to work, but I tried it in a hurry (I have softball game in a short while).
I tried this:
$message = join($_POST['group1']).join($_POST['group2']).join($_POST['group3']);
and it prints out the correct strings from my arrays in this fashion:
but I'm not sure if I can apply the correct html formatting I want thats present in my array:Code:string, string, string,etc.
edit: I'm trying to send an html email generated by my survey formCode:string string string string string string
-
06-26-2012 #7
-
06-26-2012 #8Forum Guru







- Join Date
- May 2008
- Location
- Vilano Beach, FL
- Posts
- 3,867
- Rep Power
- 62
- Points
- 17,992 (0 Banked)
OK, cool, I was going to mention that the underlying tag parser could/can occasionally get frazzled if the markup isn’t to spec.
"Remember, you're young only once but you can be immature forever."
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)





Reply With Quote



Bookmarks