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 7615993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:46:51+00:00 2026-05-31T02:46:51+00:00

I have this array named $clientinfo : [id] => 1 [dlastname] => Brown [dfirstname]

  • 0

I have this array named $clientinfo:

[id] => 1
[dlastname] => Brown
[dfirstname] => George
[dmob] => 189328937
[dlandline] => 92839283

and so on… I want to populate this form:

<li class="hidden"><label for="did">unique id:</label><input id="did" type="text" name="did" style="background-color:gray" readonly="readonly" /></li>
<li class="firstcell"><label for="dlastname">lastname:</label><input id="dlastname" type="text" name="dlastname" /></li>
<li class="middlecell"><label for="dfirstname">firstname: </label><input id="dfirstname" type="text" name="dfirstname"  /></li> 
<li class="middlecell"><label for="dmob">mob </label><input id="dmob" type="text" name="dmob" /></li>

and so on…

I am able to fill the fields using php by adding this at the end of each input tag:

value="<?php echo isset($docinfo['dlastname']) ? htmlspecialchars($docinfo['dlastname']) : ''; ?>

This works fine, but it needs me to write something at the end of each line, which is ok if the form is small but I am working on one with at least 250 fields.

I was wondering, since the input ID is the same as the keys of the associative array, if there is an easier, more automated way to fill this cells I had two things in mind, one to import the array to java and then do

 document.INPUTID.value='$clientinfo[INPUTID]';

or something like that… but I cannot figure out the specifics and the second one was to somehow add a php command at each fields’ code to write something like:

 value="<?php $id= $get_class($this); echo $clientinfo[$id]; ?>"

I dont really know how the $get_class works and it screwed up my code whenever I put it in there, but maybe someone could work something out to get the specific area’s id?

I should mention i am very new at this, so you will find errors above and i will need a very detailed explanation.

  • 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-31T02:46:52+00:00Added an answer on May 31, 2026 at 2:46 am

    if you have jQuery do this:

    <script type="text/javascript">
     <? foreach($yourArrayWithValues as $key=>$val) { ?>
           $('#<?=$key?>').val('<?=htmlspecialchars($val)?>');
     <? } ?>
    </script>
    

    otherwise do this with bare javascript:

    <script type="text/javascript">
     <? foreach($yourArrayWithValues as $key=>$val) { ?>
          document.getElementById('<?=$key?>').value = '<?=htmlspecialchars($val)?>';
     <? } ?>
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array named 'names' with strings looking like this: [name_23_something, name_25_something, name_2_something];
I want to dynamically access value of variable, let's say I have this array:
Let's say I have this array, $array = array( 'name' => 'hermet', 'emails' =>
i have this JSON: var projects_array = new Array( {name:myName1, id:myid1, index:1}, {name:myName2, id:myid2,
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have this ingredients array which contains multiple variables (like name, icon, value etc.).
I have an array in this format: $array = [ ['id' => 117, 'name'
I have this Array i wrote a function MostFreq that takes an array of
I have this array in PHP: array( [0] => array( 'username' => 'user1' )
I have this array, for example (the size is variable): x = [1.111, 1.122,

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.