Jump to content

jamesmargolis

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by jamesmargolis

  1. Thank you ch0cu3r, your solution works for me. I noticed some posts in thid forum are marked with a green "ANSWERED" (indicating that they have been fully answered I presume :-) ) and I guess this is what I should mark this post now, but I fail to see an "answered" button anywhere
  2. In the code below, I am trying to produce a google-like page where the user can type keywords and pages of search results are displayed. The main difficulty I am encountering is that when the browser changes pages, it forgets everything about current data. Perhaps I should include the display of pages inside the HTML form ? How can I fix this code ? Here is the contents of my searchpage.php file : <?php $keywords=''; $display_search_results=''; if(isset($_POST['search_submitted'])) { $keywords=$_POST['keywords']; $search_results=array(); $totalNbrOfItems=20; for($k=1;$k<=$totalNbrOfItems;$k++) { $search_results[$k]='Your keywords '$keyowrds.' have been found in item number '.$k; } $nbrOfItemsParPage = 5; $nbrOfPages = ceil($totalNbrOfItems / $nbrOfItemsParPage); // Compute current page $current_page = (isset($_GET['page']))?intval($_GET['page']):1; $display_pages=($nbrOfPages<2)?'<p>Page : ':'<p>Pages : '; for ($i = 1 ; $i <= $nbrOfPages ; $i++) { if ($i == $current_page) //No link to the current page { $display_pages=$display_pages.$i.' '; } else { $display_pages=$display_pages.'<a href="searchpage.php?'. 'page='.$i.'">'. $i . '</a> '; } } $display_pages=$display_pages.'</p>'; $display_items=''; $start=$nbrOfItemsPerPage*($current_page-1); for($k=1;$k<=$nbrOfItemsParPage;$k++) { $display_items=$display_items.($search_results[$start+$k]).'<br>'; } $display_search_results=$display_pages.$display_items; } echo '<form method="post" action="searchpage.php">'. ' Type your keywords here : <br><br>'. '<textarea cols="65" rows="1" '. 'id="keywords_id" name="keywords">'.$keywords.'</textarea>'. '<input type="submit" name="search_submitted" id="search_submitted_id" value="Search" /> '. '</fieldset>'. '</form>'; echo $display_search_results; ?>
  3. From a dropbox or an online image repository, for example. If the user chooses to upload "from his computer", everything will work as with an ordinary "input type="file"". If the user chooses to upload "from the web", he is to be provided a text field in which he will type the URL of the image/audio/video. I know this is something already implemented in many sites ; for example, if you click on the image icon in the panel at http://math.stackexchange.com/questions/ask, you get exactly what I am looking for
  4. I know about <input type="file" > which allows one to upload files from one’s computer. But now I need a pop-up window that allows the user to choose first if he uploads from his computer or from the internet. How may I achieve that ? This question is perhaps better suited for the "Javascript" or even "AJAX" forum ; if someone advises me to, I will move that question and put it in the appropriate forum.
  5. It works. Thanks! There is no way to mark a topic as solved in this forum ?
  6. I wish to display a text field with two buttons under it, and I want one of the button on the leftmost part (that’s very easy because that's the default), and the other on the rightmost part (this I don’t really know how to implement this). I am currently using something like this : <!DOCTYPE html> <html> <head> <title>Title</title> </head> <body> <fieldset> <input name="words" type="text" id="words" size="60" /><br><br> <input type="button" id="lb" name="leftbutton" value="leftbutton" /> <input type="button" id="rb" name="rightbutton" value="rightbutton" /> </fieldset> </body> </html> With this kind of code, I can adjust the number of to make the other button fit on the far right, but that’s obviously not the right way to do things. Perhaps I should use a table ? How ?
  7. Thanks for your help hansford. Your solution makes the button write something, but the <span> tag is just output "as is" instead of being interpreted as HTML code. The reason I'm putting a <span> around the character is that, if I don't, the text area starts writing right-to-left as in Hebrew after the character has been inserted. And I don't want that behavior since this is meant for texts which short quotes in Hebrew, not texts entirely written in Hebrew.
  8. I’m trying to construct a button that simply writes an "aleph" character into a text area, see below. My code does not work, can anyone tell me why ? How should I fix it ? <!DOCTYPE html> <html> <meta charset="UTF-8"> <head> <title>Example</title> <script type="text/javascript"> //JavaScript code goes here function insertAtEnd(text) { var theArea = document.getElementById("thisArea"); theArea.value += '' + text + '';; } </script> </head> <body> <input type="button" id="aleph" name="aleph" value="Write an aleph" onClick="javascript:insertAtEnd(\'<span>א</span>\');return(false)" /> <textarea id="thisArea"> </textarea> </body> </html>
  9. Now, with the code below I get the correct output except that the preview field appears outside the table even though I declare it inside <?php $text=(isset($_POST['message']))?$_POST['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%">'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br>'. $formatted_text. '</fieldset>'. '</td>'. '</table>'. '</form>';
  10. As it can only validate html not php content, it would be quite complicated for me to use it in this situation, it seems.
  11. I’m trying to write a post-panel where the user can see the preview of his post to the right of the text area he’s writing into. I tried the following into a file called writepost.php : <?php $text=(isset($_GET['message']))?$_GET['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%"><tr>'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br><p> '. $formatted_text. '</fieldset>'. '</td></tr>'. '</table>'. '</form>'; There are several things wrong with this code : 1) When the user hits the "Preview" button, I expect writepost.php to be reloaded (this is what happens), and the current content of the textarea to be stored in $_GET['message'] (this is not what happens). 2) Why does my browser output the preview part under the text area (or in other words outputs the HTML table as a single column of two cells), when I insist in my HTML code for the table to be displayed as a single row ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.