Jump to content
php.lv forumi
  • 0

Pogas ID iegūšana


m8t

Question

Tātad, pašreizējais kods:

 

<input name="question[1]" type="radio" value="1" />
<input name="question[1]" type="radio" value="2" />
<input name="time[1]" type="hiden" value=""/>
<input name="question[2]" type="radio" value="1" />
<input name="question[2]" type="radio" value="2" />
<input name="time[2]" type="hiden" value=""/>

 

Ko es gribu panākt?

 

Kad noklikšķina uz kāda radio button, tad pie attiecīgā time lauka tiek pievienots šī klikšķa laiks. Es nemāku ar JS iegūt pogas ID (question[1]). Ir kādi ieteikumi?

$(document).ready(function() {
 $("input").click(function(){
   //iegustam pogas id un tad..
   $("input[@name='time["+ID+"]']").val() = LAIKS;
 }
}

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Liels paldies, viss sanāca.

$(document).ready(function() {
$("input").click(function(){
	$time = Math.round(new Date().getTime() / 1000);
	$clickID = $(this).attr("name").match(/question\[(\d+)\]/)[1];
	$("#time_"+$clickID).html('<input name="time['+$clickID+']" type="hidden" value="'+$time+'"/>');
});
});

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...