New To Group

M

M5v0h4y1

I'm both new to the group and am having a problem getting an option
value to update to user-input from a text box on the same form.
Here's what I'm trying to do:

this is a partial script from a dynamically set list menu - I'm only
concerned with getting the Other-Employer Not Listed option to read
input from the user input into the text box "employer_alternate".

<script>
document.write('<option
value="'+document.getElementsByName(&#34employer_alternate&#34)
[0].value+'"> Other - Employer Not Listed</option>')
</script>

<input name="employer_alternate" type="text" id="employer_alternate"
value="" size="70">

Whenever I try to read the value of "employer_alternate" into the
value for the listed option either nothing happens or when I try to do
it outside of javascript like this:

<option
value="javascript:document.getElementsByName("employer_alternate")
[0].value;"> Other - Employer Not Listed</option>

I simply get my javascript as text in my transfer to a database.

I suspect this is coding 101, yet need help.

Thank you.
 
E

Evertjan.

wrote on 24 mrt 2008 in comp.lang.javascript:
I'm both new to the group and am having a problem getting an option
value to update to user-input from a text box on the same form.
Here's what I'm trying to do:

this is a partial script from a dynamically set list menu - I'm only
concerned with getting the Other-Employer Not Listed option to read
input from the user input into the text box "employer_alternate".

<script>
document.write('<option
value="'+document.getElementsByName(&#34employer_alternate&#34)
[0].value+'"> Other - Employer Not Listed</option>')
</script>

What do you expect this &#34employer_alternate&#34 would do?

alert(&#34employer_alternate&#34);

gives an error.

And getElementsByName(s) needs a string-value for s.
<input name="employer_alternate" type="text" id="employer_alternate"
value="" size="70">

Whenever I try to read the value of "employer_alternate" into the
value for the listed option either nothing happens or when I try to do
it outside of javascript like this:

<option
value="javascript:document.getElementsByName("employer_alternate")
[0].value;"> Other - Employer Not Listed</option>

Why would assigning a string to a value invoke javascript?

Only things like onload, onclick do,
and do not need the javascript: part.

Do not write script as you think it should work, but as the specs say it
does. You will sometimes even get working results before debugging time.
I simply get my javascript as text in my transfer to a database.

As it should be.
I suspect this is coding 101, yet need help.

coding 101, what is that? Why yet?

Better learn Javascript, it seems you are new to it too..
 
P

Peter Michaux

I'm both new to the group and am having a problem getting an option
value to update to user-input from a text box on the same form.
Here's what I'm trying to do:

this is a partial script from a dynamically set list menu - I'm only
concerned with getting the Other-Employer Not Listed option to read
input from the user input into the text box "employer_alternate".

<script>
document.write('<option
value="'+document.getElementsByName(&#34employer_alternate&#34)
[0].value+'"> Other - Employer Not Listed</option>')
</script>

<input name="employer_alternate" type="text" id="employer_alternate"
value="" size="70">

Whenever I try to read the value of "employer_alternate" into the
value for the listed option either nothing happens or when I try to do
it outside of javascript like this:

<option
value="javascript:document.getElementsByName("employer_alternate")
[0].value;"> Other - Employer Not Listed</option>

I simply get my javascript as text in my transfer to a database.

I suspect this is coding 101, yet need help.

If you are new to JavaScript then I think Flanagan's book is helpful.
Other contributors to comp.lang.javascript have different opinions.
The errata on the O'Reilly site is important.

<URL: http://jibbering.com/faq/#FAQ3_1>

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top