Jump to content
php.lv forumi

SELECT, INPUT skaitļu saskaitīšana


dAivEd

Recommended Posts

Čau visiem! Situātcija tāda: lietotājs izvēlas, leja uzreiz saskaita cik tas ir

 

<select name=standart_price>
<option value=100>100</option>
<option value=200>200</option>
<option value=300>300</option>
</select>
<input type=radio name=15>+15
<input type=radio name=30>+30
<input type=radio name=50>+50

Kopa: ? (selected + input)

Nu vot ideja apmēram tāda.

Link to comment
Share on other sites

dAivEd --> sac ar to ka arii radio butonam noraadi Value..

<input type=radio name="50" value="50">+50

un arii vertiibas jaliek pedinjaas

Lai dabuutu tekosho vertiibu izmanto :

< select onchange="alert(this.value)" ..

 

Protams alert ir kaa piemers ...

Link to comment
Share on other sites

To var izdarit pielietojot javascript selectam onchange uzzinat selecta vertibu

 

var dropdownIndex = document.getElementById('mySelect').selectedIndex;
var dropdownValue = document.getElementById('mySelect')[dropdownIndex].value;

 

un radio varetu dabut vertibu

var radioValue = document.getElementById(this).value; // ja shis ir onclick

Edited by cucumber
Link to comment
Share on other sites

cucumber, priekš kam tev document.getElementById(this), ja tev jau ir this objekts? Un select.value strādā tāpat kā select[select.selectedIndex].value :)

 

Un neaizmirstam, ka visas input/select/etc vērtības ir string'i, kas matemātisku darbību gadījumā jāpārvērš par integer'iem - parseInt()

Link to comment
Share on other sites

ja kluda this.value ar palidz

<input type="radio" name="rname" value="15" onclick="alert(this.value);"  />

Link to comment
Share on other sites

dAivEd --> sac ar to ka arii radio butonam noraadi Value..

<input type=radio name="50" value="50">+50

un arii vertiibas jaliek pedinjaas

Lai dabuutu tekosho vertiibu izmanto :

< select onchange="alert(this.value)" ..

 

Protams alert ir kaa piemers ...

Nu ka tas viss jaliek pediņas utt, to es visu zināju, es uz fikso roku piemēru uzrakstiju, bet ka man tagad šo visu izvadīt ? piemēram tu uzklikšķini visus radio, un leja mainās cipāri

Link to comment
Share on other sites

O jaa, tu bik latinu esi augstu uzmetis sac no javascript pamatiem http://www.w3schools.com/JS/default.asp

Link to comment
Share on other sites

paldies ka palidzejat ar parasto skriptu kas saskaita :D

Tev tachu pateica kaa to visu izdariit, kaa dabuut vertibas utt...

primitiivu JS funkciju jau nu iemacies pats uzrakstiit...

daudz jau no PHP netskjiras ( ir atskjiribas bet pamats ir taads pats)

--

Un kaa sasummet 2 vertiibas jau nu vajadzeetu pasam zinaat, to tomer maaca 1 klasiitee

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...