Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixniete zmiany w hiddenach

  • Loading branch information...
commit d5b2c03365b20d4893475ceee7a13c2b860b2f03 1 parent 1e7bb25
Karolina authored
Showing with 45 additions and 6 deletions.
  1. +24 −3 Skunk.cpp
  2. +21 −3 Skunk.hpp
View
27 Skunk.cpp
@@ -116,11 +116,32 @@ CSGI::Response Skunk::Server::get(CSGI::Env& env) {
resp.content.append("jQuery(document).bind('ready',function(){\n");
resp.content.append("var count = $('#wid_count').attr('value');\n");
resp.content.append("var i;\n");
- resp.content.append("for (i=1;i<count-1;++i){\n");
+ resp.content.append("var change_id;\n");
+ resp.content.append("var radio_count = $('#radio_count').attr('value');\n");
+
+ resp.content.append("for (i=0;i<count;++i){\n");
resp.content.append("$('#i'+i).change(function(){\n");
- resp.content.append("$('#i'+i+'_changed').val('true');");
-
+
+ resp.content.append("change_id = $(this).attr('id');\n");
+ resp.content.append("$('#'+change_id+'_changed').val('true');\n");
+
+
resp.content.append("});\n");
+
+ resp.content.append("for (j=0;j<=radio_count;++j){\n"); ///wewnetrzny for dla radio radio_count
+ resp.content.append("$('#i'+i+'_'+j).click(function(){\n");
+ resp.content.append("alert('zmieniam');");
+
+ resp.content.append("change_id = $(this).attr('id');\n");
+ resp.content.append("alert(change_id);");
+ resp.content.append("$('#'+change_id+'_changed').val('true');\n");
+
+
+ resp.content.append("});\n");
+ resp.content.append("}\n");
+
+
+
resp.content.append("}\n");
View
24 Skunk.hpp
@@ -157,6 +157,10 @@ struct RadioButton : Widget {
virtual std::string GET() {
std::stringstream id_str;
+ std::stringstream i_str;
+ std::stringstream count;
+
+ count << this->getElemsNum();
id_str << this ->id_;
std::string html = "";
html.append("<b>"+ title +"</b><br />\n");
@@ -167,18 +171,32 @@ struct RadioButton : Widget {
html.append(" value='");
html.append(""+ itoa(i));
html.append("' ");
- if(this->isDefault(i)) html.append("checked ");
- html.append(" id='i"); /// id tylko dla javascriptu
+ if(this->isDefault(i)) html.append("checked = 'checked' ");
+ html.append("id='");
html.append(id_str.str());
- html.append("'/>");
+ html.append("_");
+ i_str.str("") ;
+ i_str << i;
+ html.append(i_str.str());
+ html.append("'");
+ html.append("/>");
html.append(this->getValue(i));
html.append("<br />\n");
+
+ html.append("<input type='hidden' id='radio_count' value='");
+ html.append(count.str());
+ html.append("'/>\n");
+
html.append("<input type='hidden' name='id");
html.append(id_str.str());
html.append("_changed' ");
html.append("id='i"); /// id tylko dla javascriptu
html.append(id_str.str());
+ html.append("_");
+ i_str.str("") ;
+ i_str << i;
+ html.append(i_str.str());
html.append("_changed'");
html.append(" value='false'/>\n");
}
Please sign in to comment.
Something went wrong with that request. Please try again.