![]() |
Sending FormInput to Areabox
I am having trouble with a school assignment. I don't know much javascript and I am having trouble getting a radio selection to appear inside an areaBox. Here is my code that is not working correctly.
Code:
<html> |
This line is bogus:
Code:
sizeSelection = document.getElementByName('size').value;Put Code:
var sizeSelection = "No size selected yet";This isn't an elegant solution, but it should work. |
Why exactly does that work?
|
Because your code is doing it!
You are doing onClick="sizeSelection='Small'" so you *ARE* setting the (now global) variable sizeSelection according to what was clicked on. When you were doing Code:
sizeSelection = document.getElementByName('size').value;When you are ready, go looking (you can search in this forum) for how to get the value of the checked radio button in a set of radio buttons. Then you won't need the onclick handlers any more. |
I was able to an extra radio button but I came up on a problem when I was trying to access the info from a multi-selection form. I tried basing my code for this off of this page.
http://www.javascript-coder.com/java...t-select.phtml The biggest problem I am coming up with is how to display the info from the multi-selection with the current info. I understand that I have to call the function somewhere but I don't know how to display the info of an array in javascript in this situation. Code:
<html> |
Look into Array.join
But I think you are making a mistake using Code:
sdValues.push(oList.options[i].value);Code:
sdValues.push(oList.options[i].text); |
Quote:
Code:
<html>I think I solved the problem by changing var toppingSelectionArray=getSelectedOptions(oForm.elements["topping"];) to var toppingSelectionArray=getSelectedOptions(document.getElementById('slt_topping')); |
Yes, because no place had you defined oForm. You could have also solved it by simply defining oForm.
|
Quote:
|
Well, since your form is declared as only
<form>, you could do Code:
var oForm = document.forms[0]; // first form in the page |
Quote:
|
I don't think what you have here is an "implied language".
JavaScript is pretty darned explicit. What you have is an "implied conversion of the HTML of a page into the Document Object Model (DOM)." Yes, sometimes that conversion is by no means clear. As in the case of all forms being stuffed into the document.forms collection. Trust me, you will find worse (more obscure) to come. But don't blame JavaScript. The DOM is *NOT* part of the language. In fact, in MSIE, you can reference all DOM elements, et al., using VBScript language. And yes, all the quirks of the DOM are identical then, in either JavaScript of VBScript. |
Quote:
|
LOL! On that we are 100% agreed.
However, if you learn to use a JavaScript debugger (I like the one in Chrome, but MSIE 9 is almost identical and Firebug for FireFox is nearly as good), you *will* get all your syntax errors, and more. Not at "compile time" but at least, for syntax errors, as soon as the page is loaded. But I'm with you. I *LIKE* compiled languages. Java, C++, C#, even VB.NET in STRICT mode. |
| All times are GMT +1. The time now is 11:06 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.