Welcome to WebmasterWorld Guest from 54.158.188.59

Forum Moderators: open

Message Too Old, No Replies

Assigning an external value for a form dropdown

     
5:17 pm on Jul 25, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2002
posts:83
votes: 0


Hi

Here is the code:

THE PROBLEM IS THAT THE END VALUE READS $MyValue1 instead of the actual string. Any help would really be appreaciated.

<SCRIPT>
//set variable
$MyValue1="TEST Value"
$MyValue2="TEST Value"

document.write("<form name='test'>");
document.write("<select size=1 name=options onchange=test.text1.value=test.options.value>");
document.write(" <option>Choose one...</option>");
document.write("<option value=$MyValue1>option1</option>");
document.write("<option value=$MyValue2>option2</option>");
document.write("</select>");
document.write("<input type=text name=text1>");
document.write("</form>");
</SCRIPT>

Kind Regards

Walker

5:23 pm on July 25, 2003 (gmt 0)

Senior Member from MT 

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 1, 2003
posts:1843
votes: 0


erm you seem to be mixing javascript and PHP syntax here.

In javascript it should look liek this:

<SCRIPT>
//set variable
var MyValue1="TEST Value"
var MyValue2="TEST Value"

document.write("<form name='test'>");
document.write("<select size=1 name=options onchange=test.text1.value=test.options.value>");
document.write(" <option>Choose one...</option>");
document.write("<option value="+MyValue1+">option1</option>");
document.write("<option value="+MyValue2+">option2</option>");
document.write("</select>");
document.write("<input type=text name=text1>");
document.write("</form>");
</SCRIPT>

SN

5:31 pm on July 25, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2002
posts:83
votes: 0


THANK YOU THANK YOU.

If there is a space in the string it only carries forth the first word is there a way to get it to include all words?

Walker

5:40 pm on July 25, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2002
posts:83
votes: 0


WORKED OUT!

Apply &nbsp; inbetween each word.

5:42 pm on July 25, 2003 (gmt 0)

Senior Member from MT 

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 1, 2003
posts:1843
votes: 0


simply exchange this:

document.write("<option value="+MyValue1+">option1</option>");
document.write("<option value="+MyValue2+">option2</option>");

with this:

document.write('<option value="'+MyValue1+"'>option1</option>"');
document.write('<option value="'+MyValue2+"'>option2</option>"');

this will also validate.

SN

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members