logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-29-2009, 10:25 PM   #1
songboy
 
Join Date: Jan 2009
Posts: 115
Question removing a selected item in an html form

I have two dropdowns. A selection from the first triggers the options for the second. For both forms the clicked option is selected and moved to the top of the list. Now the problem is what if, having clicked an option in the second dropdown, the user changes their mind and goes back to the first dropdown and clicks a different item ? My script rechanges the options in list two but what I can't do is get the original list two 'selected' to disappear. I've tried everything using php but it either doesn't work or doesn't look right.
I think the answer rests with javascript. I searched around and believe I need to use another onChange statement (I've already got one for something else from DJ). I found this:
<script type="text/JavaScript">
var formObj = document.forms['product'];
onChange= formObj.mySelect.options.length = 0;
</script>
Now I think it needs to be connected with this php statement:
echo"<option value = '$experience' selected>$experience<option />";
because I want this selected variable to stop being selected when the user hits a second choice from the first dropdown.
My problem is that I have no idea how to put the two ideas together.
Could someone help ?
Songboy
PS I think this: onChange= formObj.mySelect.options.length = 0;
means...when you hit the list item, make the form 'selected' equal nothing.
Now if I'm wrong, you might just put me right.
songboy is offline   Reply With Quote
Old 01-10-2010, 12:18 AM   #2
songboy
 
Join Date: Jan 2009
Posts: 115
Default it's sorted

Hi - if you read my problem above you will no doubt be aware that my javascript idea for a solution is a non-starter. It appears that javascript doesn't influence php directly. Anyway, I went back to php and realised that one of DJ's videos did indeed have the solution - just couldn't see it at first. This does what I was looking for.

<div id="Layer61">
<select name="name_one" size="14" MULTIPLE onChange="document.forms[0].submit();">
<option value ="" selected>INNER THOUGHTS LIST<option />
<?php
@$special_word = $_POST["special_word"];
@$another_word = $_POST["special_idea"];
if($another_word)
{
echo"<option value 1 = '$another_word' selected>$another_word<option />";
}
elseif($special_word)
{
echo"<option value 1 ='' ><option />";
}
The trick is to label the option value ie 1.
songboy is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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. The time now is 11:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com