/    Sign up×
Community /Pin to ProfileBookmark

Problem in IE, but not in Firefox

Hi guys, my first time here, hope someone can help me out here.

I wrote this test code to try out a script, and it works just fine on Firefox and Netscape, but it doesn’t work too well in IE.

Here’s the complete code (HTML + JavaScript):

[code=php]<html>
<head>
<title>Test Script</title>

<script type=”text/javascript”>

function writeAll() {

document.myForm.txtQueryStr.value = “”;

tmpVar = “SELECT * FROM “;

for (i=0, len=document.myForm.selTable.length; i<len; i++) {
tmpVar += document.myForm.selTable.options[i].value;
if (i != (len – 1)) {
tmpVar += “, “;
} //if
}

document.myForm.txtQueryStr.value = tmpVar;

}

</script>

</head>

<body>

<form name=”myForm” action=”query.php” method=”post”>
<p><table>
<tr>
<td>
<select size=”5″ name=”selTable” style=”width: 100px;”>
<option>k1</option>
<option>k2</option>
<option>k3</option>
<option>k4</option>
<option>k5</option>
<option>k6</option>
<option>k7</option>
</select>
</td>
</tr></table></p>

<p>
<textarea name=”txtQueryStr” rows=”5″ cols=”100″></textarea>
</p>

<p><input type=”button” name=”btnQuery” value=”List all attributes in textbox” onClick=”writeAll();”></p>
</form>

</body>
</html>[/code]

The resulting text in Firefox is [B]SELECT * FROM k1, k2, k3, k4, k5, k6, k7[/B] (which is exactly what I want), but in IE, the resulting text is this: [B]SELECT * FROM , , , , , , [/B]

Can anyone help me figure out why this is happening? Thanks in advance!

rishi

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@pj59Jan 12.2005 — Hello!

Actually, you do not have values assigned to the options, only text. Using this:

<select size="5" name="selTable" style="width: 100px;">

<option value="k1">k1</option>

<option value="k2">k2</option>

<option value="k3">k3</option>

<option value="k4">k4</option>

<option value="k5">k5</option>

<option value="k6">k6</option>

<option value="k7">k7</option>

</select>

will help IE to understand, what you want.

Regards PJ
Copy linkTweet thisAlerts:
@rishisardhanaauthorJan 12.2005 — Thanks PJ! You're a lifesaver!

Sheesh.. who'd have thought something so simple would turn out to be such a major pain....?
Copy linkTweet thisAlerts:
@pj59Jan 12.2005 — You're welcome![i]Originally posted by rishisardhana [/i]

[B]Thanks PJ! You're a lifesaver!



Sheesh.. who'd have thought something so simple would turn out to be such a major pain....? [/B]
[/QUOTE]
It is often the tiny simple stuff which causes big pain. ?

Regards PJ
×

Success!

Help @rishisardhana spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...