Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:14:51+00:00 2026-05-28T03:14:51+00:00

I have a script as below document.getElementById(‘lan’).innerHTML=lan; document.getElementById(‘city’).innerHTML=city; document.getElementById(‘text1’).value=city+’|’+lan; The variables lan and city

  • 0

I have a script as below

    document.getElementById('lan').innerHTML=lan;
    document.getElementById('city').innerHTML=city;
    document.getElementById('text1').value=city+'|'+lan;

The variables lan and city contain text, for example ‘kalmar’.

What I want to do is to take the contents of these two variables and combine them and set that combined string to be a form field’s value, as to be able to use the regular submit function of the form to save it to database.

In Chrome and FF it works perfectly, but not in IE (surprise).
If I do alert(document.getElementById('text1').value) to see what value it holds IE only prints

[object]

Any clues as to what has happened/what I can do to make it compatible?

It’s a big document but I cut and paste the essentials here:

HTML-element to receive the final combined value

<input type='hidden' name='text1' id='text1' value=''>

HTML-element (link) to assign value to above HTML element:

<div id="searchResult"><a href="javascript:populateFields('Kalmar','Kalmar');">Kalmar i Kalmar</a><br></div>

function populateFields(lan,city)
{
    document.getElementById('lan').innerHTML=lan;
    document.getElementById('city').innerHTML=city;
    document.getElementById('text1').setAttribute('value',city+'|'+lan)
    document.getElementById('save_button').style.zIndex='auto';
alert('LAN: '+document.getElementById('lan').innerHTML);    
alert('CITY: '+document.getElementById('city').innerHTML);  
alert('TEXT1: '+document.getElementById('text1').value);    
}

Also – the alert() checks now print the correct values (i.e. Kalmar|Kalmar) but the form still doesn’t save teh value that I have set the text1 field to!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:14:51+00:00Added an answer on May 28, 2026 at 3:14 am

    So I discovered there were a number of issues here.

    First, the function populate_fields() had local variables named the same as some html elements in the document. IE does not like that, hence it printed [object] when I tried to read the value stored in my variables (since there was already an html element/DOM object with the same name, I guess my function variables just never declared).

    Once that was sorted out, I also realized that the form didn’t save my value, though it seemed that the form item had received the correct value (I checked using alert).
    Turns out that I had a nested form, I.e.

    <form>
    
    <form>
    </form>
    
    <input last inputfield of first form>
    </form>
    

    and that made IE totally disregard the last form field… for some reason none of the other browsers had a problem…

    Thanks for the attention guys!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script snippet looks like below: <ItemGroup> <files Include=*.txt></files> </ItemGroup> <Message Text=@(files)>
I have below html code <div id=divTest> Hello <input type=text id=txtID value= /> <input
I have a javascript script like this below which the 'args' contain a string
I have a function function setbid(catid) { if(catid == 30) { document.getElementById('bannerid').value = 1;
I have a NAnt script like below: <if test=${a}>${b}> <call target=target/> </if> What I
I have a NAnt script like below: <target name=Init unless=${target::has-executed('Init')}> What I want is
I have a bash script as below, and I want it to read two
I have tested the below script on a demo page which is not using
I have a Perl script which nests foreach loops as seen below. It takes
I have a python script which outputs lots of data, sample is as below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.