67 279
Assignments Done
99,1%
Successfully Done
In November 2018

Answer to Question #46968 in AJAX | JavaScript | HTML | PHP for geetanjali

Question #46968
I am calling one javascript function on, onclick event. the result I get is the text box. I have list of options and for each option I want to have seperate textbox. but currently I am getting the resultant textboxes in one horizontal line. how can I align them? for each option.?

Following is the code.


Javascript:

function showSelected(val, selectedResult2,selectedResult3,selectedResult4,selectedResult5,selectedResult6,selectedResult7,selectedResult8,selectedResult9,selectedResult10,selectedResult11,selectedResult12,selectedResult13){
document.getElementById(selectedResult2).innerHTML = " " + val;
document.getElementById('selectedResult','selectedResult2','selectedResult3','selectedResult4','selectedResult5','selectedResult6','selectedResult7','selectedResult8','selectedResult9','selectedResult10','selectedResult11','selectedResult12','selectedResult13').innerHTML += "&nbsp;<input type='text' value='' size='5' style='height:10px; margin-bottom:5px;'/>";


HTML:

<div id='selectedResult' style="height: 20p
Expert's answer
<html>
<head>
</head>
<body>
<div>
<select id="selectVal1">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult1">
</div>
</div>
<br /><br />
<div>
<select id="selectVal2">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult2">
</div>
</div>
<br /><br />
<div>
<select id="selectVal3">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult3">
</div>
</div>
<br /><br />
<div>
<select id="selectVal4">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult4">
</div>
</div>
<br /><br />
<div>
<select id="selectVal5">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult5">
</div>
</div>
<br /><br />
<div>
<select id="selectVal6">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult6">
</div>
</div>
<br /><br />
<div>
<select id="selectVal7">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult7">
</div>
</div>
<br /><br />
<div>
<select id="selectVal8">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult8">
</div>
</div>
<br /><br />
<div>
<select id="selectVal9">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult9">
</div>
</div>
<br /><br />
<div>
<select id="selectVal10">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult10">
</div>
</div>
<br /><br />
<div>
<select id="selectVal11">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult11">
</div>
</div>
<br /><br />
<div>
<select id="selectVal12">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult12">
</div>
</div>
<br /><br />
<div>
<select id="selectVal13">
<option value="val1">val1</option>
<option value="val2">val2</option>
</select>
<br /><br />
<div id="selectedResult13">
</div>
</div>
<button onclick="showSelected(document.getElementById('selectVal1').value, document.getElementById('selectVal2').value, document.getElementById('selectVal3').value, document.getElementById('selectVal4').value, document.getElementById('selectVal5').value, document.getElementById('selectVal6').value, document.getElementById('selectVal7').value, document.getElementById('selectVal8').value, document.getElementById('selectVal9').value, document.getElementById('selectVal10').value, document.getElementById('selectVal11').value, document.getElementById('selectVal12').value, document.getElementById('selectVal13').value);">Go</button>
</body>
<script type = "text/javascript">
function showSelected(){
for(i=0;i<arguments.length;i++){
document.getElementById('selectedResult'+(i+1)).innerHTML="<input type='text' value='"+arguments[i]+"' size='5' style='height:20px; margin-bottom:5px;'/>";
}
}
</script>
</html>


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions