Jump to content

jwzumwalt

Members
  • Posts

    11
  • Joined

  • Last visited

jwzumwalt's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Your code for a slideshow located at - https://www.w3schools.com/howto/howto_js_slideshow.asp will not work as written. It is missing instructions to execute the script. <body onload="showSlides()">
  2. dsonesuk - Thank you for taking the time to explain the problem AND provide the solution. I use to write most my web programs in PHP and have started to convert many of them to JS - would have never figured this out I do keep good notes, and won't have to go through this again!
  3. I am trying to get the value of a radio button. The value of the radio button should get put into the answer box. Why won't the radio value get returned and/or shown? Thx <head> <script> function test() { var myinput = document.getElementById("guess").value; document.getElementById("answer").value = myinput; } </script> </head> <body> <input type="radio" name="guess" value="1"> One<br> <input type="radio" name="guess" value="2"> Two<br> <input type="radio" name="guess" value="3"> Three<br> <input type="radio" name="guess" value="4"> Four<br> <br> <br> Answer <input type="text" id="answer" size=8 style="background-color:#cfc;"> <br> <br> <button onclick="test()">Calculate</button>  </body>
  4. That fixed it! Thanks (I am still baffled why this caused a form submission...)
  5. The link provided did not work so I could not check the source code. A better pattern match is $pattern = "/^(+d{1,2}s)?(?d{3})?[s.-]d{3}[s.-]d{4}$/"; The if statement has two errors. 1) a elseif is needed 2) a condition/check is needed for the elseif There are two else in a row; this is not allowed. it looks like the proper code should be just a single else like this... //Check for a valid phone number if (!empty($_REQUEST['phone'])) { // something was sent $phone = $_REQUEST['phone']; $pattern = "/^[0-9_]{7,20}/"; if (preg_match($pattern,$phone)){ $phone = $_REQUEST['phone']; } else { // illegal chars $errors[] = 'Your Phone number can only be numbers.'; } // end of preg_match } else { // no entry - blank $errors[] = 'You forgot to enter your Phone number.'; } // end of !emptyThis is how the code would be if more than one condition needed to be checked.// proper form of "if...elseif...else"if ( condition ) {// Type your code here} elseif ( condition ) { // other code} else { // other code} //Check for a valid phone number if (!empty($_REQUEST['phone'])) { $phone = $_REQUEST['phone']; $pattern = "/^[0-9_]{7,20}/"; if (preg_match($pattern,$phone)){ $phone = $_REQUEST['phone']; } else { $errors[] = 'Your Phone number can only be numbers.'; } else { $errors[] = 'You forgot to enter your Phone number.'; }
  6. I am not a accomplished js programmer. I am trying to get JS to fill a input box with today's date when a button is clicked. I am using Google Chrome. For some reason the code causes a form submit which I do not want because I would like other form input fields to be able to be filled in. I have done quite a few other js forms and never had this problem. What am I doing wrong? <?phpecho "<HTML> <head> <script type='text/javascript'> function bankdate() { document.getElementById('bankdate').value=Date(); } function invoicedate() { var today = '2015-01-01'; document.getElementById('invoicedate').value=today; } </script> </head> <body> <form name='myform' action='some.php' method='get'> <input type='text' id='bankdate' name='bankdate' class='tcal' size='10' value=''> <button onclick='bankdate(); return false;'>Today</button><br>Bank date</br> <input type='text' id='invoicedate' name='invoicedate' class='tcal' size='10' value=''> <button onclick='invoicedate();return false;'>Today</button><br>Invoice date </br> <br> <button type=submit>save</button> <!-- save button --> <button type=button onclick="javascript:window.location='index.php';">cancel</button> <!-- cancel button --> <button type=button onClick="window.location='" . $_SERVER['PHP_SELF'] . "'">clear</button></td> <!-- clear button --> </form><br><br> </body></html>";?>
×
×
  • Create New...