List Info

Thread: Re; trouble with inner.html




Re; trouble with inner.html
country flaguser name
Sweden
2008-03-16 02:35:08


Hi Ruth,

Let's get this straight: your JavaScript function works correctly?

If that's the case, then you're not actually having trouble with innerHTML,
right? If this is correct, then the subject of message is incorrect, and your
real problem is with processing an arbitrary number of form elements having
dynamically generated names, right?

Since you didn't say what you're using on the server to process your form, it's
not possible to offer a definitive answer/solution; however, I can tell you that
in most server-side languages/environments, you can simply loop through the
array of POST values.

For example, PHP has the $_POST array, and you can get at all form fields and
their values by looping through it like this:

foreach($_POST as $field => $value)
{
// ...
}

So if you want to do something with data from a bunch of form fields whose names
are "row1", "row2", "row3", etc., one way you can do that is like so:

foreach($_POST as $field => $value)
{
// does the name of the field contain 'row'...?
if(strpos($field, 'row') !== FALSE)
{
do_something_with($value);

// ...
}
}

I'm not going to spend any more time on this here since this is a JS list and
yours is a server-side issue, but maybe this helped get you started. If you need
more help, please ask for it on a list or forum that's specific to the
server-side language and database that you're using.

cheers

jon.

> Posted by: "Ruth Marya"; ruth.marya%40gmail.com">ruth.maryagmail.com rya_acem_manice
>; Date: Fri Mar 14, 2008 10:02 am ((PDT))
>
> Guys,
>
> I need your help,please...
>; I have problem with javascript inner.html...
> here is the code:
>
> function ExpandTable()
> {
> s="&lt;table border=0&gt;<tr>;";
> //s+=";<td bgcolor='#ffeeee' colspan=&quot;+(splitnum)+";>&lt;td colspan=&quot;
> //s+=splitnum+"&gt;<;/td>&lt;/tr>&quot;;
>; for (i=0;i<splitnum;i++){
> n++;
> ya++;
> cn++;
> pl++;
> sl++;
> jd++;
> //s+=";<tr><td width='254' class='tdHeadA'>Company Name"+n
&gt; s+="&lt;tr>&lt;td width='191' class='tdHeadA'>Year:</td><td width='191'>";
> s+="&lt;input type='text' name='yearAttend";+ya+&quot;' />";
>
> s+="&lt;tr>&lt;td width='191' class='tdHeadA'>Company Name:</td><td
> width='191'>";
> //s+=";:</td&gt;<td width='279'>";
> s+="&lt;input type='text' name='compName"+cn+&quot;' />";
> //s+=";<input type='text' name='compName' />";
> //s+=";</td>;</tr&gt;<tr>;<td class='tdHeadA'>Position Level";+n
&gt; s+="&lt;/td>&lt;/tr><tr>&lt;td class='tdHeadA'>Position Level:</td><td>&quot;
> //s+=";:</td&gt;<td&gt;"
> //s+=";<input type='text' name='positionLvl' />";
> s+="&lt;input type='text' name='positionLvl&quot;+pl+"' />";
>
> s+="&lt;/td>&lt;/tr><tr>&lt;td class='tdHeadA'>Salary:</td><td>";
> s+="&lt;input type='text' name='salary"&#43;sl+";' />";
>
> s+="&lt;/td>&lt;/tr><tr>&lt;td class='tdHeadA'>Description of Job:</td><td>"
> s+="&lt;textarea name='jobdesc"&#43;jd+&quot;' cols='60' rows='5'&gt;</textarea>&quot;
>
> s+="&lt;/td>&lt;/tr>";
&gt; }
> alert(&quot;jobdesc&quot;+jd);
> s+="&lt;/tr>&lt;/table&gt;";
> document.getElementById("q").innerHTML=s;
> }
>
> the above function will be executed when user click the following button..
>
> <input type=";button&quot; value=&quot;Add More Experience"
&gt; onClick=&quot;splitnum++;ExpandTable();">;
>
> my question is:
>
> how to insert all values into the database since the the value "jd&quot; variable
> keep increasing when the user click the button...
>
> if the user click the button 3times, then the value of "jd&quot; is 6...
>;
> I cannot insert the value of textbox whose jd value is 1,2,3,4,5....

--
This message has not been scanned for viruses.

Since I do not use a Microsoft operating
system or software, and use only plaintext
for email, there is little need for me to do so.

__._,_.___
.

__,_._,___
Re: Re; trouble with inner.html
country flaguser name
United States
2008-03-16 03:03:30

sorry Jon..

Yes the code works well, I just having trouble with how to insert the value
of each variable using ASP language and MsSql 2000...

thanx...

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )