February 22, 201115 yr i currently have a few form elements that will need long name elements <label for="Reducing your fee whilst we build your account means we can finish what we have started and you pay less. Once we finish the build you may wish to up the phrases again after you have seen the positive results. Is this of interest?" class="name">Reducing your fee ( phrases) whilst we build your account means we can finish what we have started and you pay less. Once we finish the build you may wish to up the again after you have seen the positive results. Is this of interest?</label> <input type="checkbox" name="Reducing your fee whilst we build your account means we can finish what we have started and you pay less. Once we finish the build you may wish to up the phrases again after you have seen the positive results. Is this of interest?" id="" class="required" value="yes"/>yes <input type="checkbox" name="Reducing your fee whilst we build your account means we can finish what we have started and you pay less. Once we finish the build you may wish to up the phrases again after you have seen the positive results. Is this of interest?" id="" class="required" value="no"/>no how would i go about posting the name element in php or is there ristriction on word/letter lenth in forms cannot seem to get it to post
February 22, 201115 yr Why do they need long name elements? That won't work as the name attribute is not meant for holding content. You use the name to reference it from JS/server side when the form is posted. You'd have something like: <input name="newsletter" type="checkbox" id="newsletter_check" /> <label for="newsletter_check">Really long sentence about how you should tick this bloody box yo</label> Where the label for="" references the id of the form element. edit: I should've read your profile before commenting - there's probably a reason you want to do this - though whatever it is, I cannot imagine. Good luck! Edited February 22, 201115 yr by henbast
February 22, 201115 yr Author Would you be able to expand on why you need the long name elements at all? the client needs the full questions posting to his team
February 22, 201115 yr Are you not able to use names like... <?php if (isset($_POST['question1'])) { $question1 = "Really long sentence about how you should tick this bloody box yo"; } ?> <input name="question1" value="yes" type="checkbox" /> Would that work for you? Then you can just echo the variable $question1 or am I missing something important here? Edited February 22, 201115 yr by EpicWebs
February 22, 201115 yr Author i have this code in my sendmail.php file $extras = ''; foreach ($_POST as $key => $field) { if(!in_array($key,$currently_active)) { $extras.= $key . ": " . $field . "<br /> \n"; } } If i add any fields manually to contact form, this grabs them and send them in the email also this form has no page refresh
February 22, 201115 yr Is it dynamic or do you know what the element names are going to be every time? I am wondering if you can use an if statement to check what the current field is and if it is question1 then add a certain sentence to $extras. if($field == "question1") { $extras.= $key . ": really long sentence that you already know <br /> \n"; } Let me know if I am not helping lol. Good luck!
February 22, 201115 yr Author any help is really appriciated everything was fine until they asked me to add extra fields with super long questions
February 22, 201115 yr Can you stick the questions into an array maybe? $questions = array( 'beans' => 'Do you like beans?', 'hedges' => 'Can you trim hedges?' 'dinner' => 'Something really long about what you would like for dinner?' ); Then in HTML: <?=$questions['beans']?> <input type="checkbox" value="yes" name="beans" /> Then finally in your form script: $extras = ''; foreach ($_POST as $key => $field) { if (array_key_exists($key, $questions)) { $long_key = $questions[$key]; } else { $long_key = $key; } if(!in_array($key,$currently_active)) { $extras.= $long_key . ": " . $field . "<br /> \n"; } } Edited February 22, 201115 yr by henbast
February 22, 201115 yr or stick them in a file or database and then call them in as and when they are needed. Then you won't have to keep updating the page.
February 23, 201115 yr You should really use PHP to push out the long sentences, this way you can pass a form element and value to identify which question was raised. Then it will compare it and return the long version. There are some examples above which illustrate this quite well.
Create an account or sign in to comment