Hi,
I need help with this javascript. What I’m trying to achieve is if user selects any item from list it should populate in text box if text box is already filled then it should not over ride the first one but it should populate in next available text box.
Now code is working only if the user selects list of items with CTRL and it will populate in all fields, but that’s not what I wanted they should have two options user can select one at a time all at a time.
Conditions if user already selected item from the list and if by accidentally clicks on the same item it should give a warning mesg “not allowed” unless user delete’s and re-select
and the user have choice to remove any items and select diff one at any time.
Can you guys help with this I really appreciate for your help guys.
<script language="JavaScript"><!--
function clicked(form) {
for (var i=0, j=i; i < form.selectName.options.length; i++) {
if (form.elements['currentText' + j].value = ""{
j = j++;
}
if (form.selectName.options.selected) {
form.elements['currentText' + j].value = form.selectName.options.text;
form.elements['currentValue' + j].value = form.selectName.options.value;
j++;
}
}
}
//--></script>
</head>
<body>
<form name="formName1" onSubmit="return false;" >
<select name="selectName" multiple onClick="clicked(this.form);return false;">
<option value="option 0">entry 0
<option value="option 1">entry 1
<option value="option 2">entry 2
<option value="option 3">entry 3
<option value="option 4">entry 4
<option value="option 5">entry 5
</select>
<input type="submit" value="Enter" onClick="clicked(this.form);return false;">
<input type="reset" value="clear">
<p>
Select items from the above menu, then press enter.
The following boxes will display your choices:
</p>
<p>
<input name="currentText0" type="text" value="">
<input name="currentValue0" type="text" value="">
<br>
<input name="currentText1" type="text" value="">
<input name="currentValue1" type="text" value="">
<br>
<input name="currentText2" type="text" value="">
<input name="currentValue2" type="text" value="">
<br>
<input name="currentText3" type="text" value="">
<input name="currentValue3" type="text" value="">
<br>
<input name="currentText4" type="text" value="">
<input name="currentValue4" type="text" value="">
<br>
<input name="currentText5" type="text" value="">
<input name="currentValue5" type="text" value="">
</form>
</body>
</html>
</body>
</html>
I need help with this javascript. What I’m trying to achieve is if user selects any item from list it should populate in text box if text box is already filled then it should not over ride the first one but it should populate in next available text box.
Now code is working only if the user selects list of items with CTRL and it will populate in all fields, but that’s not what I wanted they should have two options user can select one at a time all at a time.
Conditions if user already selected item from the list and if by accidentally clicks on the same item it should give a warning mesg “not allowed” unless user delete’s and re-select
and the user have choice to remove any items and select diff one at any time.
Can you guys help with this I really appreciate for your help guys.
<script language="JavaScript"><!--
function clicked(form) {
for (var i=0, j=i; i < form.selectName.options.length; i++) {
if (form.elements['currentText' + j].value = ""{
j = j++;
}
if (form.selectName.options.selected) {
form.elements['currentText' + j].value = form.selectName.options.text;
form.elements['currentValue' + j].value = form.selectName.options.value;
j++;
}
}
}
//--></script>
</head>
<body>
<form name="formName1" onSubmit="return false;" >
<select name="selectName" multiple onClick="clicked(this.form);return false;">
<option value="option 0">entry 0
<option value="option 1">entry 1
<option value="option 2">entry 2
<option value="option 3">entry 3
<option value="option 4">entry 4
<option value="option 5">entry 5
</select>
<input type="submit" value="Enter" onClick="clicked(this.form);return false;">
<input type="reset" value="clear">
<p>
Select items from the above menu, then press enter.
The following boxes will display your choices:
</p>
<p>
<input name="currentText0" type="text" value="">
<input name="currentValue0" type="text" value="">
<br>
<input name="currentText1" type="text" value="">
<input name="currentValue1" type="text" value="">
<br>
<input name="currentText2" type="text" value="">
<input name="currentValue2" type="text" value="">
<br>
<input name="currentText3" type="text" value="">
<input name="currentValue3" type="text" value="">
<br>
<input name="currentText4" type="text" value="">
<input name="currentValue4" type="text" value="">
<br>
<input name="currentText5" type="text" value="">
<input name="currentValue5" type="text" value="">
</form>
</body>
</html>
</body>
</html>