Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2010, 06:36 PM   PM User | #1
mjs
New Coder

 
Join Date: Jan 2010
Posts: 97
Thanks: 17
Thanked 0 Times in 0 Posts
mjs is an unknown quantity at this point
Hide, load, and show div with javascript

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

inside process.html
Code:
<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>

inside guest_details.html

Code:
<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>
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 show 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 by Kor; 11-26-2010 at 11:32 AM..
mjs is offline   Reply With Quote
Old 11-25-2010, 07:16 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
a) Your hiding tags <! - and -> are invalid and will cause the script to fail with asyntx error. These comment tags should be <!-- and -->. But the <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997).

b) Use <script type = "text/javascript"> rather than simply <script>.

c) Submitting the form reloads the page and starts over. You cannot modify the page after form submission has taken place.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
Philip M is offline   Reply With Quote
Old 11-26-2010, 06:52 AM   PM User | #3
mjs
New Coder

 
Join Date: Jan 2010
Posts: 97
Thanks: 17
Thanked 0 Times in 0 Posts
mjs is an unknown quantity at this point
Thanks Philip M for the corrections, that just my mistyped at here. but 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

PHP Code:
    <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>
inside of page guest_details.html as follows
PHP Code:
    <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>
inside of page first_start.html as follows
PHP Code:
    <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>
situations:

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

load('?p=guest_details')
and
load('?p=first_start')

by default guest_details.html is showing and first_start.html is hiding

Goals:
when guest_details.html form submited by click
PHP Code:
<a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_next;?> </span></a>
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
PHP Code:
<a href="<?php echo $edit_guest_details?>" class="button"> <span> <?php echo $edit_guest;?> </span></a>
clicked then guest_details.html show again

Looking for some pointers, Thanks in Advance

Last edited by mjs; 11-26-2010 at 06:57 AM..
mjs is offline   Reply With Quote
Old 11-26-2010, 11:29 AM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
Hide, load, and show div with javascript
It is not native JavaScript syntax, it should be a library/framework, we don't know which, probably JQuery. Or Prototype. Or whichever. Should we guess? Don't confound JavaScript with JavaScript libraries. In the absence of a precise nomination, a coder is not able to guess which, from over 20 different libraries, is that you might have used.

Therefor, you should have posted this Thread in the proper subForum: JavaScript Frameworks. I'll do that for you.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 11-26-2010, 01:49 PM   PM User | #5
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,812
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Does indeed look like jQuery to me. The things you are trying to do should be straightforward with jQuery, but it's hard to tell what's going on without your whole page code - preferably the rendered code without php for clarity. Can you post that?
SB65 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:33 PM.


Advertisement
Log in to turn off these ads.