Jump to content
php.lv forumi

kļūda kuru neredzu ...


snach15

Recommended Posts

sveiki, varētu lūdzu pateikt kur esmu pieļāvis kļūdu? kods nearbojas ...

 

<script type="text/javascript">
function premiumacc(type) {
	document.getElementById("premium").style.display = "none"
	document.getElementById("goldmember").style.display = "none"
	document.getElementById(type).style.display = ""
}
</script> 

<select name="premiumpack" onchange="put(this.value);">
         <option value="free" onclick="premiumacc('free')">Select</option>
         <option value="premium"  onclick="premiumacc('premium')">Premium</option>
         <option value="goldmember" onclick="premiumacc('goldmember')">Goldmember</option>
       </select>



<span id=premium style=display:none>test1</span>
<span id=goldmember style=display:none>test2</span>


Edited by snach15
Link to comment
Share on other sites

document.getElementById("premium").style.display = "none"
document.getElementById("goldmember").style.display = "none"
document.getElementById(type).style.display = ""

Kur pazuduši " ; " simboli?

 

Arī šī ir kļūda. Nevalidēsies bez "".

<span id=premium style=display:none>test1</span>
<span id=goldmember style=display:none>test2</span>

Edited by m8t
Link to comment
Share on other sites

1) moš paprovē pēdiņas palietot:

<span id="premium" style="display:none">test1</span>
<span id="goldmember" style="display:none">test2</span>

2) "put" nav definēts:

<select name="premiumpack" onchange="put(this.value);">

 

ieslēdz firebug un ieraudzīsi konsolē...

Link to comment
Share on other sites

1. kart ko nozimee nedarbojaas?

kads ir kljudas pazinjojums?

2. kur funkcija put() ??

 

3. kur ir dotajai rindinjai ID ?

document.getElementById(type).style.display = ""

tu tachu megjini noslept <option> elementu... tad vismaz iedali vinjam ID ..

4. tas kods ir apsaluuti bezjedziigs, jo nedara pilnigi neko.. vismaz ar dotajam vertibam

paskaties pats: ja ari funkcija veiksmiigi nostradaatu tad

1 rindinja noslepj spanu test 1, kas jau tapat ir noslepts

2 rindinja izdara to pashu ar test2

3 rindinja atjauno defolto vertibu konkretam optionam (kuru protams nevar atrast, jo nav id)

Edited by Grey_Wolf
Link to comment
Share on other sites

bišk saputrojos ... paldies bet tagad ir šada lieta atkal

 

kad izvēlos kādu no iptioniem man uzreiz parāda test1 test2

 

<script type="text/javascript">
       function premiumacc(type) {
               document.getElementById("premium").style.display = "";
               document.getElementById("goldmember").style.display = "";
       }
</script> 

<select name="premiumpack" onchange="premiumacc(type);">
         <option value="free" onclick="premiumacc('free')">Select</option>
         <option value="premium"  onclick="premiumacc('premium')">Premium</option>
         <option value="goldmember" onclick="premiumacc('goldmember')">Goldmember</option>
       </select>



<span id="premium" style="display:none">test1</span>
<span id="goldmember" style="display:none">test2</span>

Link to comment
Share on other sites

a ko tu citu gribēji ieraudzīt, ja viens aiz otra uzrakstīts:

                document.getElementById("premium").style.display = "";
               document.getElementById("goldmember").style.display = "";

un kāpēc tu premiumacc() sauc gan no onchange, gan no onclick?

Link to comment
Share on other sites

Nav īsti smuki, bet tavai saprašanai tā derēs. pārējo, ask google:

<script type="text/javascript">
   function premiumacc(type) {
       document.getElementById("premium").style.display = type.value == "premium" ? "" : "none";
       document.getElementById("goldmember").style.display = type.value == "goldmember" ? "" : "none";
   }
</script> 

<select name="premiumpack" onchange="premiumacc(this);">
   <option value="free">Select</option>
   <option value="premium">Premium</option>
   <option value="goldmember">Goldmember</option>
</select>

<span id="premium" style="display:none">test1</span>
<span id="goldmember" style="display:none">test2</span>

 

P.S. optimizētājus lūc nebļaut - pats zinu, ka neveikli, bet nu cilvēkam saprotamāk...

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