printing dom value

M

Mariano

I have this JS function. I read the value of input box trough the dom
path: document.q.risp.value.
onkeyup event it properly working, so every character inserted in box
open an alert windows with current value of form. But, alas, my work
is not complete cause this is just a test. My real target is to use
this value as value (sorry forwordplay :) ) of get parameter named act
(it should be appear at place of xyz). I have try in so many way, but
no one is usefull to me, and all my try write the dom path as it is
(document.q.risp.value), no one will write the current value (abc for
example). Someone coulde help me???

function myFunc (xml, user){
// ...
msg = "<form name=\"q\" onsubmit=\"return false\" method\"GET\">";
// ...
msg += '<input type="text" name="risp" value="abc"
onkeyup="alert(document.q.risp.value)"/>';
// ...

msg += '<input type="submit" name="act" value="Send"
onclick="funct(\'exec\', \'fileserver?act=xyz\' )" >';
msg += "</form>";

var target = document.getElementById("ajaxDiv");
target.innerHTML=msg;
}

thanks
PS: clearly I can't read this value as I can do in normal way with
action etc etc
 
D

Doug Gunnoe

I have this JS function. I read the value of input box trough the dom
path: document.q.risp.value.
onkeyup event it properly working, so every character inserted in box
open an alert windows with current value of form. But, alas, my work
is not complete cause this is just a test. My real target is to use
this value as value (sorry forwordplay :) ) of get parameter named act
(it should be appear at place of xyz). I have try in so many way, but
no one is usefull to me, and all my try write the dom path as it is
(document.q.risp.value), no one will write the current value (abc for
example).  Someone coulde help me???

function myFunc (xml, user){
    // ...
    msg = "<form name=\"q\" onsubmit=\"return false\" method\"GET\">";
    // ...
    msg += '<input type="text" name="risp" value="abc"
onkeyup="alert(document.q.risp.value)"/>';
    // ...

    msg += '<input type="submit" name="act" value="Send"
       onclick="funct(\'exec\',  \'fileserver?act=xyz\' )" >';
    msg += "</form>";

    var target = document.getElementById("ajaxDiv");
    target.innerHTML=msg;

}

thanks
PS: clearly I can't read this value as I can do in normal way with
action etc etc

I'm not 100% clear what you are asking, but I think you want this
sting:

'fileserver?act=' + document.getElementsByName('risp')[0].value

if this 'risp' is the first one in your document with name=risp then
[0] should work, if not change the index to whatever.
 
S

SAM

Mariano a écrit :
function myFunc (xml, user){
// ...
msg = "<form name=\"q\" onsubmit=\"return false\" method\"GET\">";
// ...
msg += '<input type="text" name="risp" value="abc"
onkeyup="alert(document.q.risp.value)"/>';
// ...

msg += '<input type="submit" name="act" value="Send"
onclick="funct(\'exec\', \'fileserver?act=xyz\' )" >';
msg += "</form>";

var target = document.getElementById("ajaxDiv");
target.innerHTML=msg;
}

thanks
PS: clearly I can't read this value as I can do in normal way with
action etc etc


innerHTML doesn't work correctly with forms !

Have a look here :
<http://stephane.moriaux.pagesperso-orange.fr/truc/innerHTML_danger>


function myFunc (xml, user){
var f = document.createElement('FORM');
f.name = 'q';
f.onsubmit = function() { return false; };
f.method = 'get';
var I = document.createElement('INPUT');
I.name = 'risp';
I.value = 'abc';
I.onkeyup = function(){funct('exec', 'fileserver?act=xyz\');};
f.appendChild(I);
var target = document.getElementById("ajaxDiv");
target.appendChild(f);
}
 
M

Mariano

I ask sorry to Doug and SAM, cause I have send them mail in place to
reply here in newsgroup.
I'm not 100% clear what you are asking, but I think you want this
sting:

'fileserver?act=' + document.getElementsByName('risp')[0].value

I have try as:
msg += '<input type="submit" name="act" value="send"
onclick="funct(\'exec\', \'fileserv?
idd='+idd[0]+'&idq='+idq[0]+'&risp='+document.getElementsByName('risp')
[0].value+'\', \'GET\')" >';

but it's wrong
hep me please :(
 
V

VK

None can help me, please?

If none of previous responses helped you, then I am afraid no one
understand what are you asking about (myself included).

Are you trying to replicate (clone) a form with all its runtime values
into some other DIV?

If not then could you give a step-by-step explanation (really short of
course) of your aim? Like "I have this, this and this, I want to do
that with it to get such and such result". I mean on the document
level, not on the level of a particular variable. Like "a have a form
on my page, it may be partially filled by user, I want to make it
exact copy and insert [here] in the same document", something like
that.
 
P

pr

Mariano said:
I ask sorry to Doug and SAM, cause I have send them mail in place to
reply here in newsgroup.
I'm not 100% clear what you are asking, but I think you want this
sting:

'fileserver?act=' + document.getElementsByName('risp')[0].value

I have try as:
msg += '<input type="submit" name="act" value="send"
onclick="funct(\'exec\', \'fileserv?
idd='+idd[0]+'&idq='+idq[0]+'&risp='+document.getElementsByName('risp')
[0].value+'\', \'GET\')" >';

You can lose the '[0]' in this line. Or write it

this.form.elements['risp'].value.
but it's wrong
hep me please :(

For future reference, 'wrong' is not a good description of an error
message or problem. Read and absorb the FAQ at <URL:
http://jibbering.com/faq/>. Start with '4.13 How do I get the value of a
form control?' and work outwards.
 
T

Thomas 'PointedEars' Lahn

pr said:
Mariano said:
msg += '<input type="submit" name="act" value="send"
onclick="funct(\'exec\', \'fileserv?
idd='+idd[0]+'&idq='+idq[0]+'&risp='+document.getElementsByName('risp')
[0].value+'\', \'GET\')" >';

You can lose the '[0]' in this line.

Certainly you can't. As the identifier indicates,
HTMLDocument::getElementsByName() always returns a NodeList:

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259
Or write it

this.form.elements['risp'].value.

That would work if the form element had only one control with the name
`risp'. If it had two or more of them,

this.form.elements['risp'][n].value.

would be required, with `n' specifying the element's index in the returned
NodeList.


PointedEars
 
P

pr

Thomas said:
pr said:
Mariano said:
msg += '<input type="submit" name="act" value="send"
onclick="funct(\'exec\', \'fileserv?
idd='+idd[0]+'&idq='+idq[0]+'&risp='+document.getElementsByName('risp')
[0].value+'\', \'GET\')" >';
You can lose the '[0]' in this line.

Certainly you can't.
[...]

Good spot. Momentary inattention there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top