1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | selectfield.options.length = 1; // // add description on top of the new entries // selectfield.options[0] = new Option('Select ('+type+')', ''); j=0; for (var i=0; i < data.length; i++) { if (data[i] == 'RETURN') { return true; } selectfield.options[j] = new Option(data[i], data[i]); j++; } return true; } </script>"; |
1 | selectfield.options[j].selected = true; |
Bestaat het 8e item wel? dan krijg je namelijk geen error maar hij zet hem er ook niet op..quote:Op dinsdag 10 mei 2005 13:17 schreef Darkomen het volgende:
mzz....
document.profile.type.selectedIndex = '8';
document.getElementById('type').selectedIndex = 8;
ikheb ook geprobeerd om de value in te vullen, maar zelfs geen javascript error... wazig
Beide werken niet bij mij
Kijk dit is hem!quote:Op dinsdag 10 mei 2005 14:14 schreef SuperRembo het volgende:
Je kan de option zelf toch op selected zetten
[ code verwijderd ]
Devver in hoofdzakelijk VB.NET en MS SqlServer. PHP, MySql, JavaScript, CSS, (X)HTML, etc. is voornamelijk hobby.quote:Op dinsdag 10 mei 2005 19:49 schreef ikke_ook het volgende:
Wat doe jij voor werk Superrembo dat je dit allemaal weet?Of is het een enorm uit de hand gelopen hobby?
quote:Op dinsdag 3 mei 2005 17:31 schreef markiemark het volgende:
hmmz vorige probleem vind ik nog even niet zo belangrijk.. het volgende probleem wel..
ik wil zoiets maken als op de volgende link: http://www.dpreview.com/reviews/sidebyside.asp
maar dan met buttons er bij voor 'move up' en 'move down'.. kent iemand zo'n script? want ik weet echt niet hoe ik dat zou moeten maken!
Klinkt interessant om uit te vogelen, ik ga eventjes logisch nadenken en wat testen, je hoord wel of het lukt.quote:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function up() { if(document.form.listbox.selectedIndex != 0) { valueSelected = document.form.listbox.options[document.form.listbox.selectedIndex].value; innerHTMLSelected = document.form.listbox.options[document.form.listbox.selectedIndex].innerHTML; valueOther = document.form.listbox.options[document.form.listbox.selectedIndex-1].value; innerHTMLOther = document.form.listbox.options[document.form.listbox.selectedIndex-1].innerHTML; document.form.listbox[document.form.listbox.selectedIndex].value = valueOther; document.form.listbox[document.form.listbox.selectedIndex].innerHTML = innerHTMLOther; document.form.listbox[document.form.listbox.selectedIndex-1].value = valueSelected; document.form.listbox[document.form.listbox.selectedIndex-1].innerHTML = innerHTMLSelected; document.form.listbox[document.form.listbox.selectedIndex-1].selected = true; } } function down() { if(document.form.listbox.selectedIndex != document.form.listbox.options.length) { valueSelected = document.form.listbox.options[document.form.listbox.selectedIndex].value; innerHTMLSelected = document.form.listbox.options[document.form.listbox.selectedIndex].innerHTML; valueOther = document.form.listbox.options[document.form.listbox.selectedIndex+1].value; innerHTMLOther = document.form.listbox.options[document.form.listbox.selectedIndex+1].innerHTML; document.form.listbox[document.form.listbox.selectedIndex].value = valueOther; document.form.listbox[document.form.listbox.selectedIndex].innerHTML = innerHTMLOther; document.form.listbox[document.form.listbox.selectedIndex+1].value = valueSelected; document.form.listbox[document.form.listbox.selectedIndex+1].innerHTML = innerHTMLSelected; document.form.listbox[document.form.listbox.selectedIndex+1].selected = true; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <form name="form"> <select name="listbox" size="10"> <option value="blaat" selected="selected">blaat</option> <option value="lol">lol</option> <option value="whehehe">whehehe</option> <option value="omg">omg</option> <option value="rofl">rofl</option> <option value="porn">porn</option> <option value="dude">dude</option> <option value="abc">abc</option> <option value="tubgirl">tubgirl</option> <option value="fok">fok</option> </select> <input type="button" value="UP" onclick="up()" /><input type="button" value="DOWN" onclick="down()" /> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | var prod = new Array(); var txt = new Array(); var arr = new Array(); prod[1] = new Array("Pantalon", 1); prod[2] = new Array("Colbert" , 5); prod[3] = new Array("Vest" , 9); prod[4] = new Array("Shirt" , 10); <!-- Onderdeel: PANTALON //--> txt[1] = "Model:"; arr[1] = new Array("Bandplooi" , 2, "Rechtmodel", 3); txt[2] = "Plooien:"; arr[2] = new Array("1 Plooi" , 3, "2 Plooien", 3, "3 Plooien", 3); txt[4] = "Omslag:"; arr[3] = new Array("Met omslag" , 4, "Zonder omslag", 4); |
Dat script doet hetzelfde al de mijne alleen doet de mijne het imo beter... Bij die je hebt gevonden moet je als je hem 2 keer naar beneden wilt hem opnieuw selecteren...quote:Op zondag 15 mei 2005 00:53 schreef markiemark het volgende:
laat maar het is me al gelukt! thnx all
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | <?php if (isset($_POST['change_order'])) { echo count($_POST['selectie']); $opties = $_POST['selectie']; for($i=0; $i<count($opties); $i++) { echo $opties[$i]; } } else { ?> <script language="javascript" type="text/javascript"> function selectAll() { for(i=0; i<document.form1.selectie.options.length; i++) { document.form1.selectie.options[i].selected = true; } } function moveUpList() { var listField = document.form1.selectie; if ( listField.length == -1) { // If the list is empty alert("There are no values which can be moved!"); } else { var selected = listField.selectedIndex; if (selected == -1) { alert("You must select an entry to be moved!"); } else { // Something is selected if ( listField.length == 0 ) { // If there's only one in the list alert("There is only one entry!\nThe one entry will remain in place."); } else { // There's more than one in the list, rearrange the list order if ( selected == 0 ) { alert("The first entry in the list cannot be moved up."); } else { // Get the text/value of the one directly above the hightlighted entry as // well as the highlighted entry; then flip them var moveText1 = listField[selected-1].text; var moveText2 = listField[selected].text; var moveValue1 = listField[selected-1].value; var moveValue2 = listField[selected].value; listField[selected].text = moveText1; listField[selected].value = moveValue1; listField[selected-1].text = moveText2; listField[selected-1].value = moveValue2; listField.selectedIndex = selected-1; // Select the one that was selected before } // Ends the check for selecting one which can be moved } // Ends the check for there only being one in the list to begin with } // Ends the check for there being something selected } // Ends the check for there being none in the list } function moveDownList() { var listField = document.form1.selectie; if ( listField.length == -1) { // If the list is empty alert("There are no values which can be moved!"); } else { var selected = listField.selectedIndex; if (selected == -1) { alert("You must select an entry to be moved!"); } else { // Something is selected if ( listField.length == 0 ) { // If there's only one in the list alert("There is only one entry!\nThe one entry will remain in place."); } else { // There's more than one in the list, rearrange the list order if ( selected == listField.length-1 ) { alert("The last entry in the list cannot be moved down."); } else { // Get the text/value of the one directly below the hightlighted entry as // well as the highlighted entry; then flip them var moveText1 = listField[selected+1].text; var moveText2 = listField[selected].text; var moveValue1 = listField[selected+1].value; var moveValue2 = listField[selected].value; listField[selected].text = moveText1; listField[selected].value = moveValue1; listField[selected+1].text = moveText2; listField[selected+1].value = moveValue2; listField.selectedIndex = selected+1; // Select the one that was selected before } // Ends the check for selecting one which can be moved } // Ends the check for there only being one in the list to begin with } // Ends the check for there being something selected } // Ends the check for there being none in the list } </script> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name="selectie[]" size="4" id="selectie" multiple> <option value="fey">feyenoord</option> <option value="aja">ajax</option> <option value="psv">psv</option> </select> <input type="button" name="up" value="up" onClick="javascript: return moveUpList();"> <input type="button" name="down" value="down" onClick="javascript: return moveDownList();"> <input type="hidden" name="change_order" value="1"> <input type="submit" name="submit" value="Verstuur" onClick="javascript: selectAll();"> <br> <br> </form> <?php } ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function get_radio_value() { for (var i=0; i < document.orderform.music.length; i++) { if (document.orderform.music[i].checked) { var rad_val = document.orderform.music[i].value; } } alert(rad_val); } //--> </SCRIPT> <FORM NAME="orderform"> Which one is your favorite?<BR> <INPUT TYPE="RADIO" NAME="music" VALUE="Rock" CHECKED> Rock<BR> <INPUT TYPE="RADIO" NAME="music" VALUE="Reggae"> Reggae<BR> <INPUT TYPE="RADIO" NAME="music" VALUE="Pop"> Pop<BR> <INPUT TYPE="RADIO" NAME="music" VALUE="Rap"> Rap<BR> <INPUT TYPE="RADIO" NAME="music" VALUE="Metal"> Metal<BR> <INPUT TYPE="button" value="check" onclick="get_radio_value()"> </FORM> |
1 2 3 4 5 6 7 | <script type="text/javascript"> //a variable that will hold the index number of the selected radio button for (i=0;i<document.test.myradio.length;i++){ if (document.test.myradio[i].checked==true) theone=i } </script> |
Quick & Dirty methode: zet je object in een div-je met een id. Als je dat ding wilt weghalen dan flikker je de innerHTML van dat id leeg.quote:Op donderdag 19 mei 2005 13:25 schreef Swetsenegger het volgende:
iemand?
Forum Opties | |
---|---|
Forumhop: | |
Hop naar: |