homepage Welcome to WebmasterWorld Guest from 174.129.76.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
javascript forms question
dawlish

10+ Year Member



 
Msg#: 67 posted 5:08 pm on Mar 12, 2002 (gmt 0)

I am populating a hidden field on a form with the following code:

<select
onChange="if (this.selectedIndex >-1) {
var t='';
for (var i=this.selectedIndex;i<this.options.length;i++) {
if (this.options[i].selected) t += this.options[i].value + '\,';
}
this.form.country.value = t;
}" multiple>
<option value="UK">one
<option value="Germany">two
<option value="USA">three
<option value="Other">four
</select>
<br>
<input type="hidden" name="country" value="">

This adds the value selected and separates each one in the hidden field with a comma.

This form resides in a members area on my site and makes up part of a registration form and is outputted by a perl script. The data submitted is added to a flat file database.

The problem I have is reading back the data when someone wants to update their details.
The modify details page is essentially the same as the register page but with the fields pre-populated with data selected on registration.

How can I modify the code above so on load it reads back the data and populates the multiple select box with values from the hidden field, but at the same time update the hidden field if the user changes their selection.

I can call the data stored in the hidden field with a variable such as $data[3]

I am learning scripting at the moment and regard myself as a novice so and help would be gratefully appreciated.

 

tedster

WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 67 posted 8:38 pm on Mar 12, 2002 (gmt 0)

>> The problem I have is reading back the data when someone wants to update their details.

I'm not clear whether this is a CGI/Perl problem for you or a Javascript problem. Do you need to pre-populate the form by "reading back" information already in the flat file?

If so, you may need some of the expertise that hangs around our server-side scripting forum.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved