Text box value in the confirmation popup

kinda hung here I have this and I am getting js in the popup.

<%= @deposit = javascript_tag
“$(‘funding_transaction_deposit’).innerHTML”
%>

<%= submit_tag 'Create', :confirm => "Are you sure you would like #{@deposit} dibits deposited?" %>

I want to display the value of a text box in the confirmation popup

anybody?

I have a text box in a form I would like the value of displayed in the
confirmation box.

On Thu, Jan 13, 2011 at 6:46 PM, Me [email protected] wrote:

kinda hung here I have this and I am getting js in the popup.

<%= @deposit = javascript_tag “$(‘funding_transaction_deposit’).innerHTML”
%>

<%= submit_tag 'Create', :confirm => "Are you sure you would like #{@deposit} dibits deposited?" %>

What if you do this:
<%= submit_tag ‘Create’, :confirm => “Are you sure you would like " +
$(‘funding_transaction_deposit’).innerHTML() + " dibits deposited?” %>

On Jan 14, 9:29pm, David K. [email protected] wrote:

What if you do this:
<%= submit_tag ‘Create’, :confirm => “Are you sure you would like " +
$(‘funding_transaction_deposit’).innerHTML() + " dibits deposited?” %>

Submit tag is probably going to escape any attempt at including actual
javascript in the confirm text (I’d consider it a bug if it didn’t).
You’re probably going to need to craft the button’s onclick by hand
(You could look at the autogenerated javascript and then replace the
confirm message with something similar to what David suggested.

Fred

compile error
/Users/chabgood/web_apps_svn_working/dibspace_unfuddle/r2/app/views/funding_transactions/_form.rhtml:15:
syntax error, unexpected $undefined
… you sure you would like " + $(‘funding_transaction_deposit’…

Is there no way to assign the val to a var and just putting it in the
string?

I had this originally:

%= @deposit = javascript_tag
“$(‘funding_transaction_deposit’).innerHTML” %>

<%= submit_tag 'Create', :confirm => "Are you sure you would like #{@deposit} dibits deposited?" %>

On Jan 16, 4:59pm, Me [email protected] wrote:

Is there no way to assign the val to a var and just putting it in the
string?

not the way submit_tag generates it’s javascript.

Ok I am doing it the manual way, how do I get the value to show up? Are
the
quotes correct?

<input id=“funding_transaction_submit” name=“commit” onclick="if
(!confirm('Are you sure you would like ’ +
$(‘funding_transaction_deposit’)

  • ’ dibits deposited?’) return false; return true;" type=“submit” />

On Jan 16, 2011, at 7:23 PM, Me wrote:

Ok I am doing it the manual way, how do I get the value to show up?
Are the quotes correct?

The simplest way to do the return true/false stuff is:

...

The return false (which happens if the confirm is cancelled) stops the
form submission directly. I imagine you could do the same with your
onclick event on the button, but putting it in the form submission
makes it pretty foolproof, since the button might not be clicked
(someone types Enter and the form submits without a click).

Walter

On Jan 16, 2011, at 11:24 PM, Me wrote:

Actually what I posted is what rails produces, I copied the
javascript from the page source. I was more interested how to get
the div id value into the string, is it a quote issue?

Oh, sorry I missed that. If you have Prototype in your page, then the
syntax to get a form field’s value is

$F(‘theIdOfTheField’)

The quotes look fine. If you don’t have Prototype, then the syntax
would be something like

getElementById(‘theIdOfTheField’).value

Walter

Actually what I posted is what rails produces, I copied the javascript
from
the page source. I was more interested how to get the div id value into
the
string, is it a quote issue?

ya is this correct?

On Jan 16, 2011, at 11:35 PM, Me wrote:

ya is this correct?

That looks right, does it work?

Walter

For what? unless you quote the relevant part of the original email and
put your responses inline anyone who happens to stumble into the middle
of your issue is unlikely to be able to help.

Best Wishes,
Peter

No I am not getting a prompt.

On Jan 17, 2011, at 5:55 PM, Me wrote:

What do you see in the Firebug console or the Safari Web Inspector?
You’re debugging JavaScript now, so use the tools that let you do that.

Walter