PDA

View Full Version : Two Questions:



Jas
05-25-2007, 11:06 PM
I have an Emailing script in PHP, but I need a JS function to finish a feature. I have a <select> tag with the users friends. When the user clicks, how can I write the name in the "to" box with out refreshing or changing the page? I know that I could just catch it in PHP via the <select> tag, but people are more used to seeing it in the To: box.

Secondly, do you know of any good drop down menu tutorials? Really *good* ones for those of us who know how to code (in PHP) but suck at JS.

Thanks!

pman
05-26-2007, 01:06 AM
Hey Jas,

I don't have any drop down menu tutorials in my favourite, but I would recommend http://www.w3schools.com . Plus, try googling, you'll find a lot out there.

As for your <select> tag feature, you could try the following. Not sure if this is exactly what you want.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Select Address</title>

<script type="text/javascript">

function addressSelected(selectField)
{
document.getElementById("toAddress").value = selectField.value ;
}

</script>

</head>

<body>

To: <input id="toAddress" type="text" size="50" ></input>
Select Address:
<select id="selectTest" onChange="addressSelected(this) ;">
<option value="friend1@dynamicdrive.com">Friend 1</option>
<option value="friend2@dynamicdrive.com">Friend 2</option>
<option value="friend3@dynamicdrive.com">Friend 3</option>
<option value="friend4@dynamicdrive.com">Friend 4</option>
<option value="friend5@dynamicdrive.com">Friend 5</option>
<option value="friend6@dynamicdrive.com">Friend 6</option>
<option value="friend7@dynamicdrive.com">Friend 7</option>
</select>

</body>
</html>



______________________

Regards

Pman
http://www.pmansLab.com

Jas
05-26-2007, 01:19 AM
What an obvious answer for the select script lol. I can't beleive I couldn't figure that out . . . .Well thanks much!

Jas
05-26-2007, 11:36 PM
Is there a way to do this by a double click? onClick is a single click, that's about all I know . . .

NVM I found the answer on www.w3schools.com