Jump to content
php.lv forumi

Nesaprotu kā lai uztaisa


snach15

Recommended Posts

kā lai es uztaisu kad piemēram katram value atsevišķi varu piešķirt vērtību .. piemēram value="2" ir 40 un tad kad piemēram paņem otro optionu tad blakus parādas 40 ..

      <select name="myList" onchange="put()">
           <option>Select</option>
           <option value="2">1</option>
           <option value="3">5</option>
           <option value="4">10</option>
           <option value="5">20</option>
           <option value="6">50</option>
         </select>

 

 

atradu kautko līdzīgu bet kautkas neiet

 

<html>
<head>
<script type="text/javascript">
function put(){
   txt=document.forms[0].myList.options[document.forms[0].myList.selectedIndex].text
   document.forms[0].favorite.value=txt
}
</script>
</head>

<body>
<form>
Select your favorite browser:
<select name="myList" onchange="put()">
 <option>Internet Explorer</option>
 <option>Netscape</option>
 <option>Opera</option>
</select>
<br><br>
Your favorite browser is: <input type="text" name="favorite" size="20">
</form>
</body>

</html>

Edited by snach15
Link to comment
Share on other sites

<select name="foo" onchange="put(this.value);">
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option>
</select>
<span id="bar"></span>
<script type="text/javascript">
 var values = {1: "2", 2: "4", 3: "6"};
 function put(key){
   document.getElementById("bar").innerHTML = values[key];
 }
</script>

Link to comment
Share on other sites

mhh galīg tas javascript man jauc galvu un nevaru pabeigt scriptu .. pirmo reiz viņu pielietoju tāpēc piedošanu par tik daudz jautājumiem ..

šobrīd nevaru tikt galā ar to pasu scriptu tik pašām beigām lai notiktu nepieciešamā darbība

 

Kā lai uztaisa tā kad piemēram es izvēlos no visiem tiem optioniem "10" un tas būtu value"3" .. kā lai uztaisa piemēram lai izvēloties šo izvēlni un uzpiežot button Removu notiktu darbība aptuveni šāda

mssql_query("UPDATE Datubaze SET punkti = punkti - "saja vietā vajadzētu lai atskaita atiecīgi pēc tā ko izvēlējās (1,5,10,20,50)" WHERE MEMB___ID = '".$_SESSION['user_login_name']."'");

un tad uzreiz vēlviena darbība

mssql_query("UPDATE Datubaze SET punkti = punkti - "saja vietā vajadzētu lai atskaita atiecīgi pēc tā ko izvēlējās (10,50,100,200,500)" WHERE MEMB___ID = '".$_SESSION['user_login_name']."'");

 

<table class="sort-table"  width="500" border="0" cellspacing="0" cellpadding="0" align="center">
 <thead>
   <tr>
     <td width="186" align="center">#</td>
     <td width="144" align="center">#</td>
     <td width="170" align="center">#</td>
     <td width="170" align="center">#</td>
   </tr>
 </thead>
 <tbody>
   <tr class="'.$tr_color.'">
     <td align="center"><? print $_SESSION['user_login_name'] ?></td>
     <td align="center"><form name="form3" method="post" action="">
       <label>
<select name="foo" onchange="put(this.value);">
 <option value="0">Select</option>
 <option value="1">1</option>
 <option value="2">5</option>
 <option value="3">10</option>
 <option value="4">20</option>
 <option value="5">50</option>
</select>

<script type="text/javascript">
 var values = {0: "", 1: "10", 2: "50", 3: "100", 4: "200", 5: "500"};
 function put(key){
   document.getElementById("bar").innerHTML = values[key];
 }
</script>
<br>

         </label>
     </form>
     </td>
     <td align="center"><span id="bar"></span></td>
     <td align="center"><form  method="post" action="test-warning.html">
       <label>
         <input type="submit" value="Remove" />
         </label>
     </form></td>
   </tr>
 </tbody>
</table>
<p> </p>

Edited by snach15
Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...