Jump to content

arbitter

Members
  • Posts

    349
  • Joined

  • Last visited

Everything posted by arbitter

  1. Not sure about this, but when writing your PHP funciton: function decode_variable(&$siteName) I think that ampersand is not needed? I could be mistaken, I've never used any php functions.
  2. Hi there it's me again, I'm starting to feel like I'm spamming the forum but I can't find the solution with my knowledge, nor with that that I can find. Here's the problem: I have a textarea with text in it. Next to the textarea there is a table cell with a border in a color. When the user has not selected the textarea, the border is green. When a user selects it, it turns orange, but if he doesn't click anything it changes to green again on blur. If something changes, it turns red immediately, even if he loses focus of the element. So these are the things that are used: onBlur, onFocus and onClick. Now as you might anticipate, I don't want it to change the color if solely an arrow or so on the keyboard is pressed. So I must find a way to get the original value of the textarea in the function, so that when that value stays the same and you lose focus the color goes green again. Whilst writing this I noticed it would be possible to include the value in the function, but since it's user input and it can contain any characters, I don't quite trust that... Or can javascript handle this safely? Anyhow; here's the script in case I wasn't clear enough: <script type='text/javascript'> function changeColor(id,color,type) { if(type== 'focus' || type == 'keydown'){ document.getElementById(id).style.borderColor=color; }else if(type=='blur' && document.getElementById(id).style.borderColor == 'orange'){ document.getElementById(id).style.borderColor='green'; }else{document.getElementById(id).style.borderColor='red';} } </script> <?php while($row = mysql_fetch_array($result)) { echo "<form name='form".$row['photoid']."'>"; echo "<table>"; echo "<tr><td>"."<img src='fotos/" . $row['photoid'] . $row['type'] . "' />"; echo "</td><td>"."<textarea rows='5' cols='30' onkeydown=\"textCounter(this.form.a".$row['photoid'].",this.form.counter);this.form.s".$row['photoid'].".disabled=false;changeColor('c".$row['photoid']."','red','keydown');\" onkeyup='textCounter(this.form.a".$row['photoid'].",this.form.counter);' id='a".$row['photoid']."' name='".$row['photoid']."' onfocus=\"changeColor('c".$row['photoid']."','orange','focus')\" onblur=\"changeColor('c".$row['photoid']."','red','blur')\">".$row['description']."</textarea>"; echo "</td><td id='c".$row['photoid']."' style='border:2px solid green;' >Hallo"; echo "</td><td>"."<input id='s".$row['photoid']."' type='button' onclick=\"update(getElementsByName('".$row['photoid']."')[0].value," . $row['photoid'] . ")\" value='sla op' disabled='disabled' />"; echo "</td><td>" . "<div id='".$row['photoid']."'></div>"; echo "</td></tr><tr><td></td><td>". "U heeft nog <input readonly type='text' name='counter' size='3' maxlength='3' value='140' /> tekens over."; echo "</td><td></td><td></td><td></td></tr></table>"; echo "</form>"; echo "<hr />"; } ?>
  3. So I have this function from somewhere on the internet, at first it didn't work for a while because I didn't know 'this.form.1' doesn't work but that their needed to be a letter in front of the 1. But that is fixed. Everything works perfectly, the only problem is that the characters don't get counted when the page loads, only when you execute the script (by pressing a button when it's active) Usually you would solve this by doing a body(onload) and load the function, problem is that the function uses 2 parameters and there are multiple textfieldcounters with variable parameters... Here the script anyways: <script type='text/javascript'> function textCounter(field, counter) { var max='140'; if (field.value.length > max) field.value = field.value.substring(0, max); else counter.value = max - field.value.length; } </script> <?php while($row = mysql_fetch_array($result)){ echo "<form name='form".$row['photoid']."'>"; echo "Afbeelding: " . $row['photoid'] . $row['type'] . "<br /> <br /> <textarea onkeydown='textCounter(this.form.a".$row['photoid'].",this.form.counter);' onkeyup='textCounter(this.form.a".$row['photoid'].",this.form.counter);' id='a".$row['photoid']."' name='" . $row['photoid'] . "' >".$row['description']."</textarea><input type='button' onclick=\"update(getElementsByName('".$row['photoid']."')[0].value," . $row['photoid'] . ")\" value='sla op' />"; echo "<div id='".$row['photoid']."'></div>"; echo "<input readonly type='text' name='counter' size='3' maxlength='3' value='140'>"; echo "<hr>"; echo "</form>"; } ?> Thanks in advance!
  4. I'm sorry kind sir, I have nought knowledge about flash, and my javascript is very poor as well. I've read the topic, but I havn't got a clue how to help you
  5. Allrighty me again, I've fixed that issue too! I just gave the input a name field containing the photoid that get's passed as well to the php file. It all works. My responses even go directly next to the correct inputfield! Here's the code another time: ajax.php <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Verbinding mislukt: " . mysql_error()); ?> <script type="text/javascript"> function update(description,photoid) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(photoid).innerHTML=xmlhttp.responseText; } } var parameters = 'description=' + description + '&photoid=' + photoid; xmlhttp.open("POST","ajaxsave.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(parameters); } </script> <html> <body> <?php mysql_select_db('test'); $result = mysql_query("SELECT * FROM ajax"); while($row = mysql_fetch_array($result)){ echo "Afbeelding: " . $row['photoid'] . $row['type'] . "<br /><br /><form name='MyForm'><input id='description' type='text' name='" . $row['photoid'] . "' value='" . $row['description'] . "'><input type='button' onclick=\"update(getElementsByName('".$row['photoid']."')[0].value," . $row['photoid'] . ")\" value='sla op' /></form>"; echo "<div id='".$row['photoid']."'></div>"; echo "<hr>"; } ?> </body> </html> ajaxsave.php <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Verbinding mislukt: " . mysql_error()); $description = $_POST['description']; $photoid = $_POST['photoid']; mysql_select_db('test'); mysql_query("UPDATE ajax SET description='".$description."' WHERE photoid='".$photoid."'"); echo 'Dit is succesvol opgeslagen!'; ?>
  6. SECOND EDIT Allright I fixed the issue of getting the photoid. Simply added the php variable Currently the script and form looks like this: <script type="text/javascript"> function update(description,photoid) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } var parameters = 'description=' + description + '&photoid=' + photoid; xmlhttp.open("POST","ajaxsave.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(parameters); } </script> <html> <body> <?php mysql_select_db('test'); $result = mysql_query("SELECT * FROM ajax"); while($row = mysql_fetch_array($result)){echo "Afbeelding: " . $row['photoid'] . $row['type'] . "<br /><br /><form name='MyForm'><input id='description' type='text' name='" . $row['photoid'] . "' value='" . $row['description'] . "'><input type='button' onclick=\"update(getElementById('description').value," . $row['photoid'] . ")\" value='sla op' /></form><hr>";} echo "<div id='myDiv'></div>"; ?> </body> </html> and my php file: <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Verbinding mislukt: " . mysql_error()); $description = $_POST['description']; $photoid = $_POST['photoid']; mysql_select_db('test'); mysql_query("UPDATE ajax SET description='".$description."' WHERE photoid='".$photoid."'"); echo $description; ?> I am aware that there aren't any filters currently, but as I said, it's purely testing purposes. Now the last problem. Currently it always takes the first ID, so the ID of whom I press the change button, that just changes that ID's description to the same description as the first ID. If you look at the code it's logical. But how do I change this? I can't change the ID because it would change everywhere, and adding another var doesn't do the trick eather...
  7. Can't seem to edit my original post... Anyhow, I fixed it, all by myself! Here's the code: <script type="text/javascript"> function update(description) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } var parameters = 'description=' + description + '&id=' + '1'; xmlhttp.open("POST","ajaxsave.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(parameters); } </script> <html> <body> <?php mysql_select_db('test'); $result = mysql_query("SELECT * FROM ajax"); while($row = mysql_fetch_array($result)){echo "Afbeelding: " . $row['photoid'] . $row['type'] . "<br /><br /><form name='MyForm'><input id='description' type='text' name='" . $row['photoid'] . "' value='" . $row['description'] . "'><input type='button' onclick=\"update(getElementById('description').value)\" value='sla op' /></form><hr>";} echo "<div id='myDiv'></div>"; ?> </body> </html> I've also fixed how it can return something. Now for the next problem; how do I send multiple variables? I want the onclick that currently does update(getElementById('description').value) to also send the value of the id to the script... So I need the value of the id that is accompanied with the description that's being changed...
  8. I just wonder why would you want to do this with div's?
  9. Hi there, After many attempts to learn ajax but never understanding the concept, I've finally gotten myself to partially understand it all, and I've made my first snippet, yet it doesn't work quite yet. the HTML with AJAX: <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Verbinding mislukt: " . mysql_error()); ?> <script type="text/javascript"> function update(description) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","ajaxsave.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(description); } </script> <html> <body> <?php mysql_select_db('test'); $result = mysql_query("SELECT * FROM ajax"); while($row = mysql_fetch_array($result)){echo "Afbeelding: " . $row['photoid'] . $row['type'] . "<br /><br /><form name='MyForm'><input id='description' type='text' name='" . $row['photoid'] . "' value='" . $row['description'] . "'><input type='button' onclick=\"update(getElementById('description').value)\" value='sla op' /></form><hr>";} ?> </body> </html> So this code creates a simple form, with an input field that has the value of the description of the image displayed. (And yes I am aware there is no image displayed, it's the tthought that counts). The images and descriptions are all taken from a database. Now, the POST should take the content in the input field completely and send this to the php file. I think it is here that my mistake is somewhere, but sites use the GET method more yet it seems safer for me to use the POST method (correct me if I'm wrong) The php file it refers to isn't that complicated, the only trouble I have there is to retrieve the POST (if it is correctly sent). Not sure whether this is correct: <?php $description = $_POST['description']; ?> Another problem I have is to return a value from the php file. Not quite sure how to do that (for example a confirmation message if it is posted correctly) I hope I'm being clear here, and I hope it isn't a stupid thingy. I'm not a javascript/ajax hero just yet. Thanks in advance.
  10. Using modrewrite will help indeed. Also you must have a robot.txt, so that google and whatever do not crawl and index that. For example, the main php of my site was index.php, but I was working on a second version on index2.php (which I would eventually replace the index.php file with), but because this index2.php had more info, it even came up higher than the original index.php file! However I'm no champ in the restriction and whole how apache and stuff works stuff
  11. I've read through so many tutorials of ajax and yet I can't seem to grasp how it works. But I guess I'll get back to re-reading and exercising the ajax basics Thanks for the reply anyways.
  12. Hi there, I'm not quite the hero in javascript, I only know PHP and even that isn't magnificent. However, I managed to make a photogallery system with PHP and MySQL. Here's the code: elseif(mysql_real_escape_string($_GET['fx'] == 'photos')) { if(!isset($_GET['sub'])) { echo 'Kies een album!'; echo "<br /><a href='http://localhost/chiro/index.php?fx=photos&album=chirokamp2010'>Chirokamp 2010</a>"; } elseif(!isset($_GET['sub2'])) { if(CleanMyDirtyData($_GET['sub']) == 'chirokamp2010'){$albumpubliek = 'Chirokamp 2010';}else{$ambumpubliek = CleanMyDirtyData($_GET['sub']);} echo "<div class='mainheader'>Album: $albumpubliek</div><br /><br />"; $album = CleanMyDirtyData($_GET['sub']); mysql_select_db('db'); $query = mysql_query("SELECT * FROM albums WHERE album='$album'"); $i = 0; echo "<center><table border='1'><tr>"; while($row = mysql_fetch_assoc($query)) { if($i == 5 || $i == 10 || $i == 15 || $i == 20 || $i == 25){echo "</tr><tr>";} echo "<td>"; echo "<a href='http://localhost/chiro/photos/" . $row['album'] . "/" . $row['photoid'] ."'>" . "<img width='120' src='http://localhost/chiro/fotos/$album/thumbs/" . $row['photoid'] . $row['type'] . "' alt='" . $row['explanation'] . "' style='opacity:0.7;filter:alpha(opacity=70)' onmouseover='this.style.opacity=1;this.filters.alpha.opacity=100' onmouseout='this.style.opacity=0.7;this.filters.alpha.opacity=70' /></a>"; echo "</td>"; $i += 1 ; } echo "</table></center>"; } else { mysql_select_db('dyfemtaw'); if($_GET['sub'] == 'chirokamp2010'){$albumpubliek = 'Chirokamp 2010';}else{$ambumpubliek = $_GET['sub'];} echo "<div class='mainheader'>Album: $albumpubliek</div><br /><a href='http://localhost/chiro/photos/chirokamp2010'>Terug naar overzicht</a><br />"; $photoid = CleanMyDirtyData($_GET['sub2']); $album = CleanMyDirtyData($_GET['sub']); $query = mysql_query("SELECT * FROM albums WHERE album='$album' AND photoid='$photoid'")or die(mysql_error()); $row = mysql_fetch_array($query)or die(mysql_error()); $photonumber = $row['id']; $previous = $photonumber -= 1; $query2 = mysql_query("SELECT photoid FROM albums WHERE album = '$album' AND id='$previous'"); $row2 = mysql_fetch_array($query2); $previousid = $row2['photoid']; $next = $row['id'] += 1; $query3 = mysql_query("SELECT photoid FROM albums WHERE album = '$album' AND id='$next'"); $row3 = mysql_fetch_array($query3); $nextid = $row3['photoid']; //getting last id $query4 = mysql_query("SELECT id FROM albums WHERE album = '$album' ORDER BY id DESC LIMIT 1"); $row4 = mysql_fetch_array($query4); if($previous == 0) { $firstcell = "<font color='grey'><<</font>"; } else { $firstcell = "<a href='http://localhost/chiro/photos/$album/$previousid'><font color='purple'><<</font></a>"; } $secondcell = "<img src='http://localhost/chiro/fotos/$album/large/$photoid" . $row['type'] . "' alt='" . $row['explanation'] . "' />"; $fourthcell = $row['explanation']; if($next == $row4['id'] += 1) { $thirdcell = "<font color='grey'>>></font>"; } else { $thirdcell = "<a href='http://localhost/chiro/photos/$album/$nextid'><font color='purple'>>></font></a>"; } echo "<center><table border='1' height='500px'><tr><td rowspan='2'>$firstcell</td><td height='450px' width='600px' align='center' valign='center'>$secondcell</td><td rowspan='2'>$thirdcell</td></tr><tr><td align='center'>$fourthcell</td></tr></table></center>"; } } Quick explanation; the url is of the form index.php?fx=photos&sub=album&sub2=photoid. When there is no photoid set, it shows a gallery of all the pictures, little transparant, and when you hover it is 100% visible. When you click on an image, you go to the photoid. So the whole page reloads with a 'sub2' in the url added. If the sub2 is set in the url, you go to a page with one picture in the center, and then on the sides buttons to go to the next photo or previous photo. Now this is done with a new link, all the same except the photoid. So the whole page reloads. Now what I want is to get this done with javascript/ajax. So that if you click to go to the next image, solely the image gets reloaded. Like this the site must load less, and if the page is too big for the user - he needs to scroll down to see the image - he mustn't rescroll every time. I'm really new to javascript and ajax, though I believe it is the future, so please explain very well, or give a well documented link. On a sidenote; for the next and previous image, I use the 'id' in the database of the picture. But if I remove one picture, the whole thing is messed up! How is this mostly done, what is stored in a database,...? Thanks!
  13. Perhaps if you give us the code you use when the amount increases, because now we haven't got a clue so it's quite hard to help.
  14. Hi there, I had the same problem, Google knew the answer. The css isn't loaded because its path also gets rewritten. To solve this, you have to put in a rewrite condition: RewriteCond %{REQUEST_URI} !\.(css|jpg|gif|png|js)$ [NC] though that didn't work for me. Using full path names does work though; instead of file.css use http://localhost/sitename/file.css
  15. don't know how to do it with an input submit button, but using a div with an onclick to submit the values, seems a method that should do it... After a single search on google: onkeypress=”return event.keyCode!=13″ within your input should do the trick.
  16. So I heard of mod_rewrite a few days ago, and would love to implement it on my site. I can rewrite some basic ones, but I'd like to keep it simple and I don't know how.. My whole page consists of an index.php page Then there's the basic ones: index.php?fx=activities index.php?fx=somethingelse Those I have managed to rewrite to mydomain.com/activities using: RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?fx=$1 [NC,L] The tricky part is where I have multiple $_GET[]'s for example: index.php?fx=photos&album=whatever and: index.php?fx=contact&info=whatever How do I manage this? Is it possible? I know I could use RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?fx=$1&album=$2 [NC,L] But that would make it work only for the photos, and actually it doesn't even do that... Is it possible to change this with mod_rewrite, or should I change the general layout of my $_GET[]'s with more universal ones?
  17. This has probably been asked here tons of times, and yes I've searched on google but I can't find a decently explained method. What I want is to be able to upload a whole directory of pictures at once. These pictures must go through the following: Be cropped in size (about 600px width/height) This must be stored in a folder under a random name A thumbnail must be made, with the same name, in another folder The location of each picture should be stored in a database What I've said here is all PHP I presume, and that I can take care of, I think. The problem is the multiuploader. I understand it can't be done in PHP, since PHP lets only 1 file per input tag, so you cannot select a directory. So this should be done with javascript/java/??? Additional questions: if I do mkdir('/pictures/$mapname/thumbs');, the 'pictures' already exists but the rest doesn't. Does it create the $mapname dir and the thumbs, or should I use 2 different mkdir's? What width is best to save the images to? What with is the best to save the thumbs to? So many more, but I'll keep it at this! I know it's a lot of questions, but it would really be handy if I could do this! Thanks in advance!
  18. Its no safer than checking an input field. just for a check; if a user submit's a form, only the input's from within that form get sent, right?
  19. Well I find it safer... And ofcourse, that I didn't come up with that... Is it possible to make the name value changeable using javascript?
  20. So you want to send the same mail to multiple contacts, am I right? I would use a while(), looking something like this: $recipient = ""; while($row = mysql_fetch_array("SELECT blabla FROM blabla")){ $recipient .= $row['email']; $recipient .= "; "; } I think that should work...
  21. arbitter

    Div issues

    In your <ul> in your else, you don't close the <ul>. for the rest, I can't spot it either. Here's your code a little more clear, still missing a </ul> <div id='status' align='right'> <?php require('scripts/status.php'); ?> </div> <div id='wrap'> <div id='header'> <h1 id='sitename'>Coding Experiments<span id='description'>Anything is possible...</span></h1> <div id='topnav'> <?php if($username){ echo"<ul>"; echo"<li><a href='index.php'>Home</a></li>"; echo"<li><a href='#'>Projects</a></li>"; echo"<li><a href='#'>Download</a></li>"; $sql = ("SELECT COUNT(message_id) AS count FROM messages WHERE to_user='$username' AND message_read='0'") or trigger_error('Error: ' . mysql_error()); $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $count = $row['count']; echo"<li><a href='inbox.php'>Inbox($count)</a></li>"; echo"<li><a href='#'>Profile</a></li>"; echo"<li><a href='#'>Account</a></li>"; echo"<li><a href='logout.php'>Logout</a></li>"; echo"</ul>"; } else { echo"<ul>"; echo"<li><a href='index.php'>Home</a></li>"; echo"<li><a href='#'>Projects</a></li>"; echo"<li><a href='#'>Download</a></li>"; echo"<li><a href='register.php'>Register</a></li>"; echo"<li><a href='login.php'>Login</a></li>"; echo"<li><a href='#'>Contact</a></li>"; } ?> </div> <div class='clear'> </div> <div id='headercolumn1'> <p class='description'></p> </div> <div id='headercolumn2'> </div> <div class='clear'> </div> </div> <div id='contents'> <div id='topbar'> <?php $query = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 1") or trigger_error('Error: ' . mysql_error()); $numrows = mysql_num_rows($query); if ($numrows > 0){ while ($row = mysql_fetch_assoc($query)){ $title = $row['title']; $content = nl2br($row['content']); $date = $row['date']; $by = $row['by']; echo"<center><font color='#FFFFFF'><h2>$title</h2></font><br>"; echo"<font color='#FFFFFF'><p>$content</p></font><br><br><br></center>"; echo" <b><font color='#FFFFFF'>Posted By: $by </font></b><br>"; echo" <b><font color='#FFFFFF' size='-4'> $date </font></b>"; echo"<div align='left'> <a href='news.php' target='_blank'><b>View More...</b></a></div>"; } } else{ echo"<h2>No news found!</h2>"; } ?> <div class='clear'> </div> </div> </div> </div>
  22. I feel kind of stupid posting another topic this fast, but I can't find a solution. So I want a table row to submit a form. Currently this is what I have for the table row: <tr> <td id='submit' colspan='2' onclick="submitForm()" style='cursor:pointer'><div class='green'>Submit.</div></td> </tr> the javascript is: function submitForm() { document.getElementById("enkel").submit(); } and the form is: <form id='enkel' method='post' action='test.php'> <select name='begindag'><?php for($i=1; $i<=31; $i+=1){echo "<option value='$i'>$i</option>";} ?> </select> <select name='beginmaand'><?php for($i=1; $i<=12;$i+=1){echo "<option value='$i'>$months[$i]</option>";} ?></select> </form> This all works fine. If I say if(isset($_POST['begindag'])){ \\execute script } It'll work fine. But how can I give this submit another value? eg when I use a pure html form; in my php code i'd check if the submit button was clicked: if(isset('$_POST['submit'])){..} I'd like to use this method here too. How can I add a value to the submit button that's posted as well? Also; it would be nice if this value could be adjusted by an onclick somewhere... Here's the whole code: <html> <?php session_start(); if(isset($_POST['begindag'])){echo "check!";} ?> <script type='text/javascript'> function hideShow(id) { var object = document.getElementById(id).style if (object.display == "none") { object.display = "table-row"; } else { object.display = "none"; } } function submitForm() { document.getElementById("enkel").submit(); } </script> <script type='text/css'> </script> <?php $months = array('1'=>'Januari','2'=>'Februari','3'=>'Maart','4'=>'April','5'=>'Mei','6'=>'Juni','7'=>'Juli','8'=>'Augustus','9'=>'September','10'=>'Oktober','11'=>'November','12'=>'December'); ?> <form id='enkel' method='post' action='test.php'> <table border='1' id='foo'> <tr> <td>Dag:</td> <td><select name='begindag'><?php for($i=1; $i<=31; $i+=1){echo "<option value='$i'>$i</option>";} ?> </select></td> </tr> <tr> <td>Maand:</td> <td><select name='beginmaand'><?php for($i=1; $i<=12;$i+=1){echo "<option value='$i'>$months[$i]</option>";} ?></select></td> </tr> <tr id='vraag'> <td colspan='2' onclick="hideShow('vraag');hideShow('datum2');hideShow('datum');hideShow('datum3')" align='center' style='cursor:pointer'>Einddatum geven?</td> </tr> <tr id='datum' style='display:none;'> <td>Einddag:</td> <td><select name='einddag'><?php for($i=1; $i<=31; $i+=1){echo "<option value='$i'>$i</option>";} ?> </select></td> </tr> <tr id='datum2' style='display:none;'> <td>Eindmaand:</td> <td><select name='eindmaand'><?php for($i=1; $i<=12;$i+=1){echo "<option value='$i'>$months[$i]</option>";} ?></select></td> </tr> <tr id='datum3' style='display:none'> <td colspan='2' onclick="hideShow('vraag');hideShow('datum');hideShow('datum2');hideShow('datum3')" align='center' style='cursor:pointer'>Geen einddatum geven</td> </tr> <tr> <td id='submit' colspan='2' onclick="submitForm()" style='cursor:pointer'><div class='green'>Activiteit toevoegen.</div></td> </tr> <tr> <td colspan='2' onclick="submitForm('dubbel')" style='cursor:pointer'>Activiteit toevoegen.</td> </tr> </table> </form> </html>
  23. Oh my such a simple solution! And the absolute position isn't even needed! Thanks a lot!
  24. Hi there, So I have this problem where I'm hiding a table row, and when I wish to display it, the table gets all messed up. <table border='1'> <tr> <td>Dag:</td> <td><select name='begindag'><?php for($i=1; $i<=31; $i+=1){echo "<option value='$i'>$i</option>";} ?> </select></td> </tr> <tr> <td>Maand:</td> <td><select name='beginmaand'><?php for($i=1; $i<=12;$i+=1){echo "<option value='$i'>$months[$i]</option>";} ?></select></td> </tr> <tr id='vraag'> <td colspan='2' onclick="hideShow('vraag');hideShow('datum2');hideShow('datum');" align='center' style='cursor:pointer'>Einddatum geven?</td> </tr> <tr id='datum' style='display:none;'> <td>Einddag:</td> <td><select name='einddag'><?php for($i=1; $i<=31; $i+=1){echo "<option value='$i'>$i</option>";} ?> </select></td> </tr> <tr id='datum2' style='display:none;'> <td>Eindmaand:</td> <td><select name='eindmaand'><?php for($i=1; $i<=12;$i+=1){echo "<option value='$i'>$months[$i]</option>";} ?></select></td> </tr> </table> and the hideShow() is simply: function hideShow(id) { var object = document.getElementById(id).style if (object.display == "none") { object.display = "block"; } else { object.display = "none"; } }[code] I've tried by giving my table an absoulte position, but it doesn't work, still messes it up... when showing the hidden rows, both <td>'s get shown in one column, causing the first two rows' first cell to expand.
×
×
  • 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.