mishkin
06-11-2006, 06:53 PM
OK, here's the problem, hopefully someone will have better luck than me.
I'm trying to get the value of a textbox using DOM within a function (sounds easy eh?). My site is highly dynamic so the document object model is used everywhere, this is the first problem i've run into.
If my text box were to look like this:
<input type="text" id="test">
And my function something like this:
<script>
function go()
{
something = document.getElementById("test").value
}
</script>
If I run the function this way I get an alert box with the value of "test":
<script>
function go()
{
something = document.getElementById("test").value
alert(something)
}
</script>
HOWEVER, the script breaks if I do this:
<script>
function go()
{
something = document.getElementById("test").value
return something
}
somethingelse = go()
alert(somethingelse)
</script>
I've even tried to return a something else like this:
<script>
function go()
{
something = document.getElementById("test").value
anotherSomething = 1
return anotherSomething
}
alert(anotherSomething)
</script>
Even that wouldn't work :(
It seems that each time I use DOM in a function, the function loses its ability to return a value, but retains all other functionality. :/
HELP!!!!!!
I'm trying to get the value of a textbox using DOM within a function (sounds easy eh?). My site is highly dynamic so the document object model is used everywhere, this is the first problem i've run into.
If my text box were to look like this:
<input type="text" id="test">
And my function something like this:
<script>
function go()
{
something = document.getElementById("test").value
}
</script>
If I run the function this way I get an alert box with the value of "test":
<script>
function go()
{
something = document.getElementById("test").value
alert(something)
}
</script>
HOWEVER, the script breaks if I do this:
<script>
function go()
{
something = document.getElementById("test").value
return something
}
somethingelse = go()
alert(somethingelse)
</script>
I've even tried to return a something else like this:
<script>
function go()
{
something = document.getElementById("test").value
anotherSomething = 1
return anotherSomething
}
alert(anotherSomething)
</script>
Even that wouldn't work :(
It seems that each time I use DOM in a function, the function loses its ability to return a value, but retains all other functionality. :/
HELP!!!!!!