Jump to content

Chrex

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by Chrex

  1. How can I hide (display="none") the table from the beginning on? 1. I tried to edit the ccs of the table. --> The table is always hidden, even by clicking "show". .Table { display:none;} 2. I tried to tell the js to hide the table first and by clicking "show" to show the table. --> Table is shown from the beginning on. <script type="text/javascript">document.getElementById("agbs").style.display = "none";function hideElem() { document.getElementById("agbs").style.display = "none"; }function showElem() { document.getElementById("agbs").style.display = ""; }</script> 3. I tried to give js a variable from php. --> I guess that is not possible. <script type="text/javascript">var ABC ="<?php echo $ABC ?>";if (ABC = ""){ document.getElementById("agbs").style.display = "none";}function hideElem() { document.getElementById("agbs").style.display = "none"; }function showElem() { document.getElementById("agbs").style.display = ""; }</script>
  2. Guys, you are great! That was the hint I needed! Here the code from w3schools: <img id="myImg" src="w3javascript.gif" width="100" height="132"><br><button type="button" onclick="hideElem()">Hide image</button><button type="button" onclick="showElem()">Show image</button><script>function hideElem() { document.getElementById("myImg").style.visibility = "hidden"; }function showElem() { document.getElementById("myImg").style.visibility = "visible"; }</script> There is still one question left. How can I "delete" the white space which appears when I hide the element? I read something about display:none. But I have no idea how to use it. I tried to hide a table....that works....but the following doesnt: <table class="Table" display="none" id="abc">
  3. Thanks for the hint. Im not familiar with js. Usually I prefer php, but couldnt find an easy and propper solution. Could you tell me where exactly I have to look for "expand selection options" at your recommended link? Or do I have to start from the very beginning? In this case I would switch to the php forum.
  4. Hi guys, Im looking for a propper solution to expand selection options. I want the user to answer a question with "yes" or "no". if the user clicks "yes", there shall appear more selection options. If the user clicks "no" the additional selection options shall not be shown. The second question in my code shall be hidden, except the user clicks "yes". In this case i dont want the user to click submit, the second question shall appear immediately with the click on "yes". <form action="checkboxen.php" method="post"><p>Do you have a car?</p> <input type="checkbox" name="yesno" value="yes">Yes<br/> <input type="checkbox" name="yesno" value="no"/>NO<br/><p>How many cars do you have?</p> <input type="checkbox" name="number" value="1"/>ONE<br/> <input type="checkbox" name="number" value="2"/>TWO<br/> <input type="checkbox" name="number" value="3"/>THREE<br/> <input type="submit" value="Submit"/></form> Im grateful for any ideas, examples and help. Chrex
  5. Thanks for the hint! I took my value from the session and did it like this: $value = $_SESSION['name']; $valueText = $xml->createTextNode($value); It works
  6. Hey guys, I´m using a session now. For now it is an easy solution. I´ll see if it will work with my future requirements. Thanks for your help again!
  7. Hi guys, I try to build an xml document with php. Creating, saving and sending works fine. Just couldnt figure out how to insert a variable to my php-code, which creates the xml. <?php$xml = new DOMDocument("1.0", "utf-8";$root = $xml->createElement("ABC");$xml->appendChild($root);$var1 = $xml->createElement("Town");$var1Text = $xml->createTextNode('$townname');$var1->appendChild($varText);$BCD = $xml->createElement("Data");$BCD->appendChild($var1);$root->appendChild($BCD);$xml->formatOutput = true;echo "<xmp>". $xml->saveXML() ."</xmp>";$xml->save("energieausweis.xml") or die("Error");?> Instead of using a fix "createTextNode" I wanna use a variable. Something like "createVariableNode" (I know that this doesnt exist). Hope you guys understand me. I get a variable from a form, lets say $townname, which can be Vancouver or Paris. This variable shall be written in my xml. Depending on the selection from the form, my xml shall contain Vancouver or Paris and not just the text "$townname". Thanks a lot for your help!
  8. If(input is valid) { <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <input type="submit" name="submit" value="Submit"/> </form> }else { <form method="post" action="page2.php"> <input type="submit" name="submit" value="Submit"/> </form> } Thanks, that could solve the problem. I just dont know where to put the form. Would it be like the code above? Wouldnt I have two forms then?
  9. Forget everything below the first form.....that doesnt work. The code until the end of the first form is from "here", from w3schools (see my reference). How would they transfer the data to page2.php?
  10. <?php// define variables and set to empty values$nameErr = $emailErr = $genderErr = $websiteErr = "";$name = $email = $gender = $comment = $website = "";$Error = "0";if ($_SERVER["REQUEST_METHOD"] == "POST") {if (empty($_POST["name"])) {$nameErr = "Name is required";$Error = "1";} else {$name = test_input($_POST["name"]);// check if name only contains letters and whitespaceif (!preg_match("/^[a-zA-Z ]*$/",$name)) {$nameErr = "Only letters and white space allowed";}}if (empty($_POST["email"])) {$emailErr = "Email is required";$Error = "1";} else {$email = test_input($_POST["email"]);// check if e-mail address syntax is validif (!preg_match("/([w-]+@[w-]+.[w-]+)/",$email)) {$emailErr = "Invalid email format";}}if (empty($_POST["website"])) {$website = "";} else {$website = test_input($_POST["website"]);// check if URL address syntax is valid (this regular expression also allows dashes in the URL)if (!preg_match("/b(??:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website)) {$websiteErr = "Invalid URL";$Error = "1";}}if (empty($_POST["comment"])) {$comment = "";} else {$comment = test_input($_POST["comment"]);}if (empty($_POST["gender"])) {$genderErr = "Gender is required";$Error = "1";} else {$gender = test_input($_POST["gender"]);}}function test_input($data) {$data = trim($data);$data = stripslashes($data);$data = htmlspecialchars($data);return $data;}?><h2>Headline</h2><p><span class="error">* required field.</span></p><form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">Name: <input type="text" name="name" value="<?php echo $name;?>"/><span class="error">* <?php echo $nameErr;?></span><br/><br/>E-mail: <input type="text" name="email" value="<?php echo $email;?>"/><span class="error">* <?php echo $emailErr;?></span><br/><br/>Website: <input type="text" name="website" value="<?php echo $website;?>"/><span class="error"><?php echo $websiteErr;?></span><br/><br/>Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea><br/><br/>Gender:<input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female"/>Female<input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male"/>Male<span class="error">* <?php echo $genderErr;?></span><br/><br/><input type="submit" name="submit" value="Submit"/></form><form method="post" action="page2.php"><input type="submit" name="submit" value="Weiter"/></form><?phpif ($Error == 0 && $name != "") {echo "<script>window.location = 'http://......com/page2.php'</script>";}?> Thats my code on page1.php. On the bottum I tried to insert a 2nd form. (doesnt work) You can find my idea number 5) below that. (doesnt work) Actually I´m not sure if this is a html-form, because it contains php. How ever, I try to send the variables to page2.php. Is there an easy way to do it? I dont know if a database is the right tool, because I dont rellay want to store the data. My goal is a summary on page2.php and to give the user a chance to prove his entered values. After that the data will be put in a XML and send to an email. That means I dont need the data after this point any longer.
  11. I refer: w3schools.com/php/php_form_complete.asp I dont use a Javascript. If I understood the exampe right, it submits the variables back to the form.
  12. Hi there, I´m new at this forum and a beginner with PHP. I used the here offert "PHP - Complete Form Example" and it works fine. Thanks for that.But the submit button just proves the form and doesnt send the variables to the next page. Does anyone know a way to send the proven variables to another page? I tried: 1) Print the variable on my secound page with echo $var; --> that didnt work. I guess my secound page doesnt know where to get the variable from. I also dont know where and if my variables are saved after I press the submit button on my page. 2) Create two actions in the form like <form action="<?php echo htmlspecialchars($SERVER[...]);?>"> action=page2.php method="post"> That also didnt work. Probably because you cant use 2 actions in one form. 3) I dont want to work with url links, because you can see the variables in the url. 4) I dont want to work with sessions. 5) One of my ideas was to work with another php-script after my form, which will send my variables from the form to the secound page. I figured out how to activate the scrip, when the form is filled out correctly, but I have no idea how to send my data. How would it work with the here offert form? Thanks for your help guys.
×
×
  • Create New...