Jump to content
alexarpad2003

Help with a select

Recommended Posts

Posted

Am un select :

<select name="selector">

<OPTION value="" selected>Tip</OPTION>

<OPTION value="1" selected>masina</OPTION>

<OPTION value="1" >televizor</OPTION>

<OPTION value="1" >telefon</OPTION>

<OPTION value="9" >portofel</OPTION>

</select>

Problema e ca nu pot modifica value la nici o optiune.

Cum as putea returna pe alta pagina cu POST ceea ce selecteaza userul ? Nu vreau valorile de la value, vreau sa-mi returneze masina, televizor etc.

Am nevoie de o idee.

Posted (edited)

Se poate face cu javascript.Parca innerhtml.Vin imediat cu rezolvarea.

Gata am gasit, uite aici link catre exemplu de la w3schools.

Si uite aici codul care iti returneaza intr-un window nou ce ai ales:


<html>
<head>
<script type="text/javascript">
function displayResult()
{
var x=document.getElementById("mySelect").selectedIndex;
var y=document.getElementById("mySelect").options;
var a=window.open();
a.document.write("Your choice was " + y[x].text);
}
</script>
</head>
<body>

<form>
Select your favorite fruit:
<select name="selector" id="mySelect" onChange="displayResult();">
<OPTION value="" selected>Tip</OPTION>
<OPTION value="1" selected>masina</OPTION>
<OPTION value="1" >televizor</OPTION>
<OPTION value="1" >telefon</OPTION>
<OPTION value="9" >portofel</OPTION>
</select>
</form>
</body>
</html>

Edited by razer_krait
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...