Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Should I use ajax to submit the message sent from a simple contact form or not?

     

    What is usually done with contact forms nowadays?

     

    It is just a simple contact form where a user will be able to communicate with the site admins

  2. My project(developed locally with NetBeans) has the following structure:

     

    http://localhost/Appointments/Administrator/

    http://localhost/Appointments/Frontend/

     

    I have a file in the Admin folder http://localhost/Appointments/Administrator/logout.php

     

    which I want it to access a file in the frontend folder http://localhost/Appointments/Frontend/login.php

     

    with this code which is found at logout.php:

    header("Location: /..Frontend/login.php");

    The result is this:

    Not Found

    The requested URL /Appointments/Administrator/..Frontend/login.php was not found on this server.

    How do I have to structure the dir above so that I can have access to login.php. Surely, I could copy login.php to the admin

    dir but I think this would be redundant.

  3. Why not just verify the data in serverside language and if it is empty update column value with null?

    I just want to learn triggers.

    Your idea, though, is not bad.

    What php code I could write to achieve what I mention above...I have already tried some but it did not work, something in the syntax was and that

    is why I am asking your help.

  4. I am trying to achieve something using a trigger but I do not know if it is even possible.

     

    The logic is this:

    Set a column value to NULL if an update is made where an empty string goes to the table column...this will be coming from

    an empty form input field.

     

    Thanks

    form

    I am using ajax to update a db table where it contains data sent from a form.

     

    In this form there is a wwwaddress field where the user can enter(if he want to) his/her website url-it is optional.

     

    My question is the following:

     

    I have selected that the wwwaddress data contained in the input field even if it is empty(meaning an empty string which means the user has not filled it) will be sent either way in the server for updating the table column where the web address of the user is kept.

     

    The question is if it something "bad" from a database point of view, having a column where it might have empty strings?

     

    That said, if 10 users choose not to fill the corresponding input field the table will have a column with 10 empty strings.

  5. I have come across in the web with various code examples regarding url validation.

     

    Nonetheless I want to hear from you also what code might work here-based on your experience.

     

    Obviously we are talking here about a Regular Expression.

  6. Recently, in a tutorial I came across with this syntax:

    var prop, obj = { name: "Joe", job: "Coder", age: 25 };  

    I really cannot understand what the prop is doing there.

     

    It is like assigning the object to 2 variables, furthermore in the w3schools tutorials about object creation

    I saw nowhere similar syntax.

     

    So, what the above means?

    Unless the writer of the code is making a mistake.

  7. It needs to be a string.

    Οκ...Ι fixed that...you will see the code in a while...but there is something else that I really cannot figure out,first the ajax code:

      $('#nextday').click(function(){         event.preventDefault();                $.ajax({      type: "GET",      url: "testajaxcalendar.php",      dataType:'text',      data:{newdate:"29-06-2013"},      cache:false        });                    });

    Here is what the console outputs in chrome dev tools whenever I click the above link and an ajax request is made:

     

    XHR finished loading: "http://localhost/Appointments/Administrator/testajaxcalendar.php?newdate=29-06-2013&_=1372359365989".

     

    This 1372359365989 seems to be a unix timestamp but I HAVE NO IDEA where it came from?

    Here is the html of the link:

    <a id="nextday" href="/Appointments/Administrator/Calview.php?newdate=28-06-2013&dayview"><img src="Images/day_next.png"></a>

    Above you see, 28-06-2013 as newdate....this is just printed from php...for sending through ajax and for testing I put 29-06-2013.

    But what bothers me is that unix timestamp which is sent with AJAX...what its origin might be?

  8. Well, you probably need to send it the correct date to go to. Do you understand dsonesuk's post, why the date value you're sending is -1993? Changing the date to 27 doesn't really show that you understand what's going on.
    I did understand why I got 1993(it is the result of subtraction of the numbers I sent).How am I going to send the date?
  9. This is the PHP code that changed the day in a calendar(the calendar always shows the current day and with code shown belowthe user can go back or forward day by day).

    datecalculation($newdate);if (isset($_GET['newdate'])) {	 $newdate = $_GET['newdate'];	 datecalculation($newdate);} <ul id="dayshow">			 <li><a href="<?php echo $_SERVER["PHP_SELF"]. "?newdate=". $prevDay . '&dayview' ?>"><img id="prevday" src="Images/day_prev.png"></a></li>		    <li><?php echo $now->format('j'.'  '.$monthNames1[$now->format('n')].'Y')?></li>		    <li> <?php var_dump($nextDay); ?> </li>		    <li><a href="<?php echo $_SERVER["PHP_SELF"]. "?newdate=". $nextDay . '&dayview' ?>"><img id="nextday" src="Images/day_next.png"></a></li>			 </ul>

    There is also a function called datecalculation which as it's name implies makes the date calculationsand for the sake of brevity I am not showing(If the need arises I will). The aim here is to make the above work with ajax...I have failed so far.Here is the js:

    $('#nextday').click(function(){	   event.preventDefault();		 $.ajax({	  type: "GET",	  url: "Calview.php",	  dataType:'dataString',	  data:{"newdate":26-06-2013},	  cache:false,	 });	  });

    For testing purposes I 've set a date of 26-06-2013.It does not work though and in the Chrome Dev Tools, in the error console here is the link that is sent.Calview.php?newdate=-1993&_=1372187956455". It must be the date but I do not understand why it goes to the server with the above format.

  10. if it is not much trouble can you post some code? Further more, the checked radio button may change from time to time...it will not be the same all the time. P.S Still struggling to get a grip with js syntax...that is why I am insisting on posting code

  11. I am trying to combine the 2 codes above(yours and w3scool's) so as to achieve what I want since both come close but do not give me what exactly what I want. Your code displays the values...I want it though to display the ids. What alteration must be done here?

  12. Ι am going to start another way...what is the js action that can alter the selection of a radio button in a form. For example...having a button that upon clicked by the user a selection is made of a specific radio button.Let us start with this.

  13. I have a form with some radio buttons.These radio buttons appear on clicking an edit icon and are hidden when either the user chooses to save or cancel form submission And suppose there is a default selection and the user goes to change that(as part of updating his profile)...nothing weird so far. But...after he makes a selection...he decides to cancel form submission...meaning the old check box selected should stays as it is. The problem is that it does not.After clicking the edit icon again to make the radio buttons show the selected shown is NOT the original as it should be(since the user hit the cancel button) but the changed one. I hope you understood what I am talking about.

  14. Your answer is exactly what I wanted to get started talking about solutions...I am not experienced in js/ajax and that is why I am having difficulty in finding a proper coding solution.Nonetheless, I found it, I will delete the onchange(not necessary as you mention) code and just send all the values either way, as you propose in one your solutions-THANKS.On submit-this code:

    var btype=$( "input:checked" ).val();  

    And it does the job-at least so far..Any comments are welcome.

  15. ... Another way to consider it is that if they don't update a particular element in the form, then there's no reason to send that to the server, the data didn't change. That's another way to approach the update process...
    Your explanation of the event-driven nature of js is very good but I am going to focus on the above sentence as it is the source of the problemHere is the jquery function that performs the update:
    $.ajax({	  type: "POST",	  url: "testajax.php",	  data: {"name":name,"lastname":lastname,"btype":btype}	 });

    If the user does not update btype(which is part of the form where he selects the business category where he belongs in) btype is empty/undefined.If that is the case and the user updates only name-lastname, these last 2 will not be updated because if btype is undefined it somehow spoils the update process of name/lastname. That is why I wanted to UPDATE anyway btype(by re sending the same value to the server) EVEN if is not updated by the user. I hope you understand now the problem.

  16. look...this form has 3 fields,:name, lastname and businesstype.There is a case where the user will NOT select a new radio button and leave it as it is...from the previous time(remember this is an edit profile page). This is the case where he chooses to update ONLY the name and the last name.In such a case I must get the value(and the label) of the radio button as it currently is and send it with AJAX. The user does not select another radio button in the above case and as such there is no change event. Did you got it now?

×
×
  • Create New...