Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Page with JS 2

Status
Not open for further replies.

Kalisto

Programmer
Joined
Feb 18, 2003
Messages
997
Location
GB
Hi. I have a simple problem, and I know I have solved this before, but I am on a tight deadline, so I am hoping someone in here can help me out.

I hav a page, and a requirement to give the customer instant feedback on the option they have selected. So for example I might have

Code:
<a href="javascript:form.answerTb.Text='Yes'">Yes</a>
<a href="javascript:form.answerTb.Text='No'">Yes</a>

This works for me at present after a fashion. I would prefer though, for the js to write to a literal or label control, not a textbox. And in addition to that, whenver the above code is run, the answer appears in the text box, and then the page redirects to a blank page displaying just the answer.

so, Most importantly, how do I stop it redirecting to a new page, and secondly, what do I change to make it write to a label, not a textbox

Cheers

K
 
so, Most importantly, how do I stop it redirecting to a new page,

Code:
<a href="javascript:form.answerTb.Text='Yes'[COLOR=red]; return false;[/color]">Yes</a>


and secondly, what do I change to make it write to a label, not a textbox
Code:
<a href="javascript:[COLOR=blue]document.getElementByID('mylabelid').innerText[/color]='Yes'[COLOR=red]; return false;[/color]">Yes</a>

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Damn, theres me givign you a star, and that doesnt even work. I guess I should have tried it first.

Solution 1 - I get "Return outside function" error message

Solution 2 - Object Doesnt support this type of operation.

Any other ideas?

K
 
A slight modification should take care of that problem:
Code:
<a href="[red][b]#" onclick="[/b][/red]form.answerTb.Text='Yes'; return false;">Yes</a>
<a href="[red][b]#" onclick="[/b][/red]document.getElementByID('mylabelid').innerText='Yes'; return false;">Yes</a>

Lee
 
Nope, the above didnt work either.

Ive even tried making it a function

all I get is

"Microsoft JScript runtime error: Object doesn't support this property or method"


Code:
function updateAnswer(txt){document.getElementByID('customer_response_answer').innerText=txt;}
 
Okay, I'm embarrassed. As many times as I've talked about this, I didn't notice the misspelled method when I copied and pasted previous text:

document.getElementByI[red]d[/red]()

Lee
 
Ah, cheers :)

Its working now, so ta

K

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top