Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected listbox id value included in link - client side scripting

Status
Not open for further replies.

JamesCliff

Programmer
Feb 16, 2005
106
GB
Ok, i am very very new to javascripting. Infact ive never done it in my life.

I am only attempting it now because i need client side scripting which php cannot do.

Basiclly is it possible to integrate java and php together? I ask this because this is my scenario:

I have a php script which populates a listbox from a mysql table called brisk_users with the id and username from the table. I wanted it so when a row is selected in the listbox the specific id for that row is then stored within a variable which is then included in a URL link which posts the ID to another page. However i am told php cannot do this and i need to use java or something that will do client side scripting for what im after.

Using java how can i achieve what im trying to do above.
You must forgive my explanation attempt been so brief and to the point, but i really havent got a clue what to do lol.

Any help would be greatly appriciated.

Thanks

Jim
 
Like this?
Code:
<html>
<head>
<script language="JavaScript">

function getSelectBoxValue(selectBox){
  var value = selectBox[selectBox.selectedIndex].value;
  return value;
}

function showSelectedUser(){
  location.href='yourPage.php?ID=' +
    getSelectBoxValue(document.myForm['users']);
}

</script>
</head>
<body>
<form name="myForm">
<select name="users">
  <option value="3">Bob
  <option value="5">Sue
</select>
<a href="#" onclick="showSelectedUser();return false">Show Selected User</a>

To learn more about JavaScript, try here.

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top