PDA

View Full Version : Hide / Show content with dropdown list


Rob_Che
10-02-2008, 11:56 PM
DJ has kindly offered to help me with this at the weekend but I'm too damn impatient :)

So. I'll try my best to be clear; Open these pages;
http://sherbetpips.com/main.htm
http://sherbetpips.com/hide-reveal-content.html

I want to use the "hide/show for a div" within the form on the SherbetPips site... I want to use the drop down list for "Would you like the gift delivering on your behalf" YES / NO.

I want the drop down option to do 2 things;
Capture the value for shipping but also to hide/show the hidden div.

Can it be done (by me) ?

Cheers
RC

Rob_Che
10-03-2008, 12:23 AM
Here's the code that I hoped would work...

<div class="shipping">
<select name="shipping" size="1">
<option value="2.5"><a href="#" onClick="document.getElementById('idHidden').style.display= 'none'">No</a></option>
<option value="3.5"><a href="#" onClick="document.getElementById('idHidden').style.display= 'block'">Yes</a></option>
</select>

<div id='idHidden'>
Delivery Address
<input type="hidden" name="on4" value="Delivery Address">
<input type="text" name="os4" maxlength="200">
Gift Tag Message...
<input type="hidden" name="on5" value="Gift Tag Message">
<input type="text" name="os5" maxlength="100">
</div>
</div>



#idHidden
{
display:none;
width:400px;
}

davidj
10-03-2008, 06:43 AM
ok

first can your host support PHP

we could do this using Javascript but not everyone has JS switched on

davidj
10-03-2008, 06:48 AM
how does your gateway require the data

Rob_Che
10-03-2008, 08:14 AM
ok
first can your host support PHP
we could do this using Javascript but not everyone has JS switched on
Yes I do have PHP support.



how does your gateway require the data
Hmmmm... It's capturing the data for Paypal in this instance.
Not sure if that's what you need - but it's all I have ! :o

Cheers DJ.

Rob_Che
10-03-2008, 08:18 AM
My only worry in coding something from scratch is I think I may just be missing something vey simple in what I have..

We'll see !

domedia
10-03-2008, 01:50 PM
Careful with the word 'capture' because you're not sending the form upon closing the DIV. It's a regular form element so you just want the value sent when the form is being submitted.

You need a little js function where onfocus=> set display property to none.

BTW: You're navigation still does not work, the links are not on the buttons.

Rob_Che
10-03-2008, 04:09 PM
You need a little js function where onfocus=> set display property to none.

Cheers Dom, how would I format it? JS baffles me.
So will this only work if JS is on? I can't have that, I though it could be done with HTML. How come it works on the other page ?
http://sherbetpips.com/hide-reveal-content.html

BTW: You're navigation still does not work, the links are not on the buttons.

Yeah, I've stupidly set the header to full width and haven't contained the nav div so it changes depending on screen res ! clever hey... oops.
Still not worked the hover out either... I moved on, it was killing me.

The form div dives out of the wrapper div in IE too. awesome.
So many problems, so little time ! (and that's just personally !)

Rob

davidj
10-03-2008, 06:57 PM
i can help but it will be Saturday

unless you get it sorted

i advise that you don't use JS and use PHP as you have that environment available to you

domedia
10-03-2008, 07:44 PM
He is just showing/hiding a DIV. Why would you use PHP for it?
Would you use PHP for flyout navigation as well? ;-)

Rob_Che
10-03-2008, 07:54 PM
Now now boys let's not be silly.

DJ - I think I'm going to scrap it if it means using Javascript (for the show/hide part)
I want to make it accessible to all . . .

Cheers all
Rob

davidj
10-04-2008, 09:53 AM
He is just showing/hiding a DIV. Why would you use PHP for it?
Would you use PHP for flyout navigation as well? ;-)

the way i interpreted it was to not only show / hide fields but also pass the info onto the gateway

what happens to those lost sales where JS is switched off

isn't it better to cater for all ?

i know im a programmer but my logical mind is screaming ....

"lets get money from everyone not just javaS people"

just a mindless thought process which is probably complete madness !

davidj
10-04-2008, 09:59 AM
err lets keep it friendly as people are complaining!

déjà vu!

domedia
10-05-2008, 04:48 PM
what happens to those lost sales where JS is switched off They see the regular HTML and no loss of functionality. It's called Unobtrusive JavaScript. The front end coding is maturing, it doesn't have to be wild west anymore ;)