Hide, load, and show div

Discussion in 'HTML & Website Design' started by s.jns, Nov 25, 2010.

  1. #1
    I have a few pages from each other to interact with page with id load, as below:

    inside process.html
    
    <div id="guest_details"> </div>
    
    <div id="first_start"> </div>
    <script>
    <! -
    $('#guest_details').load('?p=guest_details.html');
    $('#first_start').load('?p=first_start.html')
    $('#guest_details').hide('slow');
    $('#first_start').SlideUp('slow')
    ->
    </Script>
    Code (markup):

    inside guest_details.html

    <form action="guest_details.php" <form method="POST" id="guest">
    <!-- Some cell here -->
    <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_submit;?> </span> </a>
    
    </Form>
    Code (markup):
    That I want is when the submit button is clicked then:

    1. data sent to guest_details.php
    2. If the data has been sent then hide <div id="guest_details"> </div>
    3. showing the <div id="first_start"> </div>

    but when I make it like the above, that not work, Could someone give a clue how to correct?

    Thanks a lot
     
    Last edited: Nov 25, 2010
    s.jns, Nov 25, 2010 IP
  2. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #2
    You should read at jQuery website about the commands you are using.

    it is not SlideUp ... it is slideUp.

    AFAIK this here:

    
    ?p=guest_details.html
    
    Code (markup):
    won't work at all.

    And I did not know that a html file can handle PHP commands... (inside guest_details.html).

    jQuery .ajax should be the way to go. Go read about it
     
    CSM, Nov 25, 2010 IP
  3. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Thanks for the corrections

    for SlideUp it just mistyped it should be slideUp or show

    but the load page for ?p=guest_details is work, that doesn't work is the submit button, mean can't send the data, won't hide or show the div but still refreshing the page. any pointer please to solve this?
     
    s.jns, Nov 25, 2010 IP
  4. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    I will complete that code, hope someone can help me and I would appreciate it.

    Here the complete code:

    I have a few pages from each other to interact with page with id load, as below:

    inside of page process.html as follows

    
        <form action="<?php echo $send; ?>" method="post" id="choose">//data send to process.php and redirect back to ?p=process (process.html page)
        <!--some options here -->
        <a onclick="$('#choose').submit();" class="button"> <span> <?php echo $button_next;?> </span></a>
        </form>
        
        <?php //if ($this->options->hasChosed()) { ?>
        <div id="guest_details"> </div>
        <?php //} ?>
        
        <?php if (isset($this->session->data['guest'])) { ?>
        <div id="first_start"> </div>
        <?php } ?>
        
        <script type="text/javascript">
        <!--
        $('#guest_details').load('?p=guest_details');
        $('#first_start').load('?p=first_start');
        $('#guest_details').hide('slow');
        $('#first_start').show('slow')
        -->
        </Script>
    PHP:
    inside of page guest_details.html as follows
        <form action="<?php echo $send; ?>" method="POST" id="guest">//data send to guest_details.php and redirect back to ?p=process (process.html page)
        <!-- Some cell here -->
        <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_next;?> </span></a>
        </Form>
    PHP:
    inside of page first_start.html as follows
        <form action="<?php echo $send; ?>" method="POST" id="_start">/data send to first_start.php and redirect back to ?p=process (process.html page)
        <!-- Some cell here -->
        <a href="<?php echo str_replace($edit_guest_details); ?>" class="button"> <span> <?php echo $edit_guest;?> </span></a>
        <a onclick="$('#_start').submit();" class="button" id="f_start"> <span> <?php echo $button_next;?> </span></a>
        </Form>
    PHP:
    situations:

    page guest_details.html and first_start.html load inside process.html with using

    load('?p=guest_details')
    Code (markup):
    and
     load('?p=first_start')
    Code (markup):
    by default guest_details.html is showing and first_start.html is hiding

    Goals:
    when guest_details.html form submited by click
    <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_next;?> </span></a>
    PHP:
    then hide the page guest_details.html and show first_start.html

    now at first_start.htm page

    guest_details.html should be hide even so page refresh(f5), but

    when button
    <a href="<?php echo $edit_guest_details; ?>" class="button"> <span> <?php echo $edit_guest;?> </span></a>
    PHP:
    clicked then guest_details.html show again

    Looking for some pointers, Thanks in Advance
     
    s.jns, Nov 25, 2010 IP
  5. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Show us an example that is ONLINE. It's hard to fix with code snippets since I want to debug it.
     
    CSM, Nov 25, 2010 IP
  6. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Hi CSM,

    Sorry, not online yet, it just created at local desktop

    Thanks
     
    s.jns, Nov 25, 2010 IP
  7. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #7
    Well, as I said before you need to use .ajax function because you need a response from guest_details.php to continue

    Just typing

    
    <!--
        $('#guest_details').load('?p=guest_details');
        $('#first_start').load('?p=first_start');
        $('#guest_details').hide('slow');
        $('#first_start').show('slow')
        -->
        </Script>
    
    Code (markup):
    is not enough. You should learn some basics on how to use jQuery and AJAX.

    Besides that, if your site is XHTML then you need to write in lowercase ... </Script> will make it invalid.

    
    <a onclick="$('#guest').submit();" class="button" id="first_start">
    
    Code (markup):
    is not part of a form and is not submitting anything. use

    
    <input type="submit" class="button" id="first_start" value="<?php echo $edit_guest;?>" />
    
    Code (markup):
    or

    
    <button type="submit"...
    
    Code (markup):
    Read here about form buttons : http://www.daaq.net/old/xhtml/index.php?page=xhtml+button+fields&parent=xhtml+forms
     
    CSM, Nov 25, 2010 IP
  8. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #8
    How can you parse PHP without a webserver?

    If I can not see the full code/process... then I can't help.

    Good luck
     
    CSM, Nov 25, 2010 IP
  9. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    With something such as XAMPP or WAMP
     
    GWiz, Nov 26, 2010 IP
  10. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #10
    Hi CSM,

    I Using Xampp that bundled apache, mysql, filezilla, mercury
     
    s.jns, Nov 26, 2010 IP